diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionCollection.cs new file mode 100644 index 0000000000000..3adeae9f7edce --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionCollection.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; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_MarketplaceRegistrationDefinitionCollection + { + // Get Registration Definitions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationDefinitions() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this MarketplaceRegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + MarketplaceRegistrationDefinitionCollection collection = client.GetMarketplaceRegistrationDefinitions(scopeId); + + // invoke the operation and iterate over the result + string filter = "planIdentifier eq 'publisher.offerIdentifier.planName.version'"; + await foreach (MarketplaceRegistrationDefinitionResource 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 + MarketplaceRegistrationDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Registration Definitions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationDefinitions() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this MarketplaceRegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + MarketplaceRegistrationDefinitionCollection collection = client.GetMarketplaceRegistrationDefinitions(scopeId); + + // invoke the operation + string marketplaceIdentifier = "publisher.product.planName.version"; + MarketplaceRegistrationDefinitionResource result = await collection.GetAsync(marketplaceIdentifier); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceRegistrationDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Registration Definitions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRegistrationDefinitions() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this MarketplaceRegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + MarketplaceRegistrationDefinitionCollection collection = client.GetMarketplaceRegistrationDefinitions(scopeId); + + // invoke the operation + string marketplaceIdentifier = "publisher.product.planName.version"; + bool result = await collection.ExistsAsync(marketplaceIdentifier); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionResource.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionResource.cs new file mode 100644 index 0000000000000..b714e4b796f8a --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_MarketplaceRegistrationDefinitionResource.cs @@ -0,0 +1,46 @@ +// 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; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_MarketplaceRegistrationDefinitionResource + { + // Get Registration Definitions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationDefinitions() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this MarketplaceRegistrationDefinitionResource created on azure + // for more information of creating MarketplaceRegistrationDefinitionResource, please refer to the document of MarketplaceRegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string marketplaceIdentifier = "publisher.product.planName.version"; + ResourceIdentifier marketplaceRegistrationDefinitionResourceId = MarketplaceRegistrationDefinitionResource.CreateResourceIdentifier(scope, marketplaceIdentifier); + MarketplaceRegistrationDefinitionResource marketplaceRegistrationDefinition = client.GetMarketplaceRegistrationDefinitionResource(marketplaceRegistrationDefinitionResourceId); + + // invoke the operation + MarketplaceRegistrationDefinitionResource result = await marketplaceRegistrationDefinition.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceRegistrationDefinitionData 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/tests/Generated/Samples/Sample_RegistrationAssignmentCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationAssignmentCollection.cs new file mode 100644 index 0000000000000..63d231b65a25f --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationAssignmentCollection.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; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagedServices.Models; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_RegistrationAssignmentCollection + { + // Get Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // invoke the operation + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + RegistrationAssignmentResource result = await collection.GetAsync(registrationAssignmentId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // invoke the operation + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + bool result = await collection.ExistsAsync(registrationAssignmentId); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Put Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // invoke the operation + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + RegistrationAssignmentData data = new RegistrationAssignmentData() + { + Properties = new RegistrationAssignmentProperties("/subscriptions/0afefe50-734e-4610-8a82-a144ahf49dea/providers/Microsoft.ManagedServices/registrationDefinitions/26c128c2-fefa-4340-9bb1-6e081c90ada2"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registrationAssignmentId, data); + RegistrationAssignmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Registration Assignments + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationAssignments() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // invoke the operation and iterate over the result + await foreach (RegistrationAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Registration Assignments with ManagedByTenantId eq filter + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdEqFilter() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // invoke the operation and iterate over the result + string filter = "$filter=managedByTenantId eq '83abe5cd-bcc3-441a-bd86-e6a75360cecc'"; + await foreach (RegistrationAssignmentResource 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 + RegistrationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Registration Assignments with ManagedByTenantId in filter + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdInFilter() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationAssignmentCollection collection = client.GetRegistrationAssignments(scopeId); + + // 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 (RegistrationAssignmentResource 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 + RegistrationAssignmentData 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/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationAssignmentResource.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationAssignmentResource.cs new file mode 100644 index 0000000000000..e1f3eef386f82 --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationAssignmentResource.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagedServices.Models; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_RegistrationAssignmentResource + { + // Get Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationAssignmentResource created on azure + // for more information of creating RegistrationAssignmentResource, please refer to the document of RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationAssignmentResourceId = RegistrationAssignmentResource.CreateResourceIdentifier(scope, registrationAssignmentId); + RegistrationAssignmentResource registrationAssignment = client.GetRegistrationAssignmentResource(registrationAssignmentResourceId); + + // invoke the operation + RegistrationAssignmentResource result = await registrationAssignment.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/DeleteRegistrationAssignment.json + // this example is just showing the usage of "RegistrationAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationAssignmentResource created on azure + // for more information of creating RegistrationAssignmentResource, please refer to the document of RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationAssignmentResourceId = RegistrationAssignmentResource.CreateResourceIdentifier(scope, registrationAssignmentId); + RegistrationAssignmentResource registrationAssignment = client.GetRegistrationAssignmentResource(registrationAssignmentResourceId); + + // invoke the operation + await registrationAssignment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Put Registration Assignment + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutRegistrationAssignment() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationAssignmentResource created on azure + // for more information of creating RegistrationAssignmentResource, please refer to the document of RegistrationAssignmentResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationAssignmentResourceId = RegistrationAssignmentResource.CreateResourceIdentifier(scope, registrationAssignmentId); + RegistrationAssignmentResource registrationAssignment = client.GetRegistrationAssignmentResource(registrationAssignmentResourceId); + + // invoke the operation + RegistrationAssignmentData data = new RegistrationAssignmentData() + { + Properties = new RegistrationAssignmentProperties("/subscriptions/0afefe50-734e-4610-8a82-a144ahf49dea/providers/Microsoft.ManagedServices/registrationDefinitions/26c128c2-fefa-4340-9bb1-6e081c90ada2"), + }; + ArmOperation lro = await registrationAssignment.UpdateAsync(WaitUntil.Completed, data); + RegistrationAssignmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationAssignmentData 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/tests/Generated/Samples/Sample_RegistrationDefinitionCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationDefinitionCollection.cs new file mode 100644 index 0000000000000..b0ae1de0db66d --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationDefinitionCollection.cs @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using System.Xml; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagedServices.Models; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_RegistrationDefinitionCollection + { + // Get Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + RegistrationDefinitionResource result = await collection.GetAsync(registrationDefinitionId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + bool result = await collection.ExistsAsync(registrationDefinitionId); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Put Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/PutRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + RegistrationDefinitionData data = new RegistrationDefinitionData() + { + Properties = new RegistrationDefinitionProperties(new Authorization[] + { +new Authorization("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc","acdd72a7-3385-48ef-bd42-f606fba81ae7") +{ +PrincipalIdDisplayName = "Support User", +},new Authorization("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc","18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +PrincipalIdDisplayName = "User Access Administrator", +DelegatedRoleDefinitionIds = +{ +Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c") +}, +} + }, "83abe5cd-bcc3-441a-bd86-e6a75360cecc") + { + Description = "Tes1t", + EligibleAuthorizations = +{ +new EligibleAuthorization("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2","ae349356-3a1b-4a5e-921d-050484c6347e") +{ +PrincipalIdDisplayName = "Support User", +JustInTimeAccessPolicy = new JustInTimeAccessPolicy(MultiFactorAuthProvider.Azure) +{ +MaximumActivationDuration = XmlConvert.ToTimeSpan("PT8H"), +ManagedByTenantApprovers = +{ +new EligibleApprover("d9b22cd6-6407-43cc-8c60-07c56df0b51a") +{ +PrincipalIdDisplayName = "Approver Group", +} +}, +}, +} +}, + RegistrationDefinitionName = "DefinitionName", + }, + Plan = new ManagedServicesPlan("addesai-plan", "marketplace-test", "test", "1.0.0"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registrationDefinitionId, data); + RegistrationDefinitionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get Registration Definitions + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationDefinitions() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/GetRegistrationDefinitions.json + // this example is just showing the usage of "RegistrationDefinitions_List" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation and iterate over the result + await foreach (RegistrationDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Registration Definitions with ManagedByTenantId eq filter + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationDefinitionsWithManagedByTenantIdEqFilter() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/GetRegistrationDefinitionsWithManagedByTenantIdEqFilter.json + // this example is just showing the usage of "RegistrationDefinitions_List" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation and iterate over the result + string filter = "$filter=managedByTenantId eq '83ace5cd-bcc3-441a-hd86-e6a75360cecc'"; + await foreach (RegistrationDefinitionResource 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 + RegistrationDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Get Registration Definitions with ManagedByTenantId in filter + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetRegistrationDefinitionsWithManagedByTenantIdInFilter() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/GetRegistrationDefinitionsWithManagedByTenantIdInFilter.json + // this example is just showing the usage of "RegistrationDefinitions_List" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); + RegistrationDefinitionCollection collection = client.GetRegistrationDefinitions(scopeId); + + // invoke the operation and iterate over the result + string filter = "$filter=managedByTenantId in (83ace5cd-bcc3-441a-hd86-e6a75360cecc, de83f4a9-a76a-4025-a91a-91171923eac7)"; + await foreach (RegistrationDefinitionResource 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 + RegistrationDefinitionData 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/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationDefinitionResource.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationDefinitionResource.cs new file mode 100644 index 0000000000000..53a188ffedb48 --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/Generated/Samples/Sample_RegistrationDefinitionResource.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using System.Xml; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagedServices.Models; + +namespace Azure.ResourceManager.ManagedServices +{ + public partial class Sample_RegistrationDefinitionResource + { + // Get Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationDefinitionResource created on azure + // for more information of creating RegistrationDefinitionResource, please refer to the document of RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationDefinitionResourceId = RegistrationDefinitionResource.CreateResourceIdentifier(scope, registrationDefinitionId); + RegistrationDefinitionResource registrationDefinition = client.GetRegistrationDefinitionResource(registrationDefinitionResourceId); + + // invoke the operation + RegistrationDefinitionResource result = await registrationDefinition.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Delete Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/DeleteRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationDefinitionResource created on azure + // for more information of creating RegistrationDefinitionResource, please refer to the document of RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationDefinitionResourceId = RegistrationDefinitionResource.CreateResourceIdentifier(scope, registrationDefinitionId); + RegistrationDefinitionResource registrationDefinition = client.GetRegistrationDefinitionResource(registrationDefinitionResourceId); + + // invoke the operation + await registrationDefinition.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Put Registration Definition + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/preview/2022-01-01-preview/examples/PutRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this RegistrationDefinitionResource created on azure + // for more information of creating RegistrationDefinitionResource, please refer to the document of RegistrationDefinitionResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + string registrationDefinitionId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ResourceIdentifier registrationDefinitionResourceId = RegistrationDefinitionResource.CreateResourceIdentifier(scope, registrationDefinitionId); + RegistrationDefinitionResource registrationDefinition = client.GetRegistrationDefinitionResource(registrationDefinitionResourceId); + + // invoke the operation + RegistrationDefinitionData data = new RegistrationDefinitionData() + { + Properties = new RegistrationDefinitionProperties(new Authorization[] + { +new Authorization("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc","acdd72a7-3385-48ef-bd42-f606fba81ae7") +{ +PrincipalIdDisplayName = "Support User", +},new Authorization("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc","18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +PrincipalIdDisplayName = "User Access Administrator", +DelegatedRoleDefinitionIds = +{ +Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c") +}, +} + }, "83abe5cd-bcc3-441a-bd86-e6a75360cecc") + { + Description = "Tes1t", + EligibleAuthorizations = +{ +new EligibleAuthorization("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2","ae349356-3a1b-4a5e-921d-050484c6347e") +{ +PrincipalIdDisplayName = "Support User", +JustInTimeAccessPolicy = new JustInTimeAccessPolicy(MultiFactorAuthProvider.Azure) +{ +MaximumActivationDuration = XmlConvert.ToTimeSpan("PT8H"), +ManagedByTenantApprovers = +{ +new EligibleApprover("d9b22cd6-6407-43cc-8c60-07c56df0b51a") +{ +PrincipalIdDisplayName = "Approver Group", +} +}, +}, +} +}, + RegistrationDefinitionName = "DefinitionName", + }, + Plan = new ManagedServicesPlan("addesai-plan", "marketplace-test", "test", "1.0.0"), + }; + ArmOperation lro = await registrationDefinition.UpdateAsync(WaitUntil.Completed, data); + RegistrationDefinitionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegistrationDefinitionData 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/tests/autorest.tests.md b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/autorest.tests.md new file mode 100644 index 0000000000000..606ab7b13d0d4 --- /dev/null +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/tests/autorest.tests.md @@ -0,0 +1,13 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateTest` to generate code. + +# Azure.ResourceManager.ManagedServices.Tests + +> see https://aka.ms/autorest +``` yaml +require: ../src/autorest.md +include-x-ms-examples-original-file: true +testgen: + sample: true +``` \ No newline at end of file diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_PartnerResponseCollection.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_PartnerResponseCollection.cs new file mode 100644 index 0000000000000..211a82c38da7b --- /dev/null +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_PartnerResponseCollection.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Identity; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ManagementPartner +{ + public partial class Sample_PartnerResponseCollection + { + // GetPartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetPartnerDetails() + { + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/GetPartnerDetails.json + // this example is just showing the usage of "Partner_Get" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this 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"; + PartnerResponseResource result = await collection.GetAsync(partnerId); + + // the variable result is 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}"); + } + + // GetPartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetPartnerDetails() + { + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/GetPartnerDetails.json + // this example is just showing the usage of "Partner_Get" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this 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"; + bool result = await collection.ExistsAsync(partnerId); + + Console.WriteLine($"Succeeded: {result}"); + } + + // PutPartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this 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/tests/Generated/Samples/Sample_PartnerResponseResource.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_PartnerResponseResource.cs new file mode 100644 index 0000000000000..9a91d191acf36 --- /dev/null +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_PartnerResponseResource.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.ManagementPartner +{ + public partial class Sample_PartnerResponseResource + { + // GetPartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetPartnerDetails() + { + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/GetPartnerDetails.json + // this example is just showing the usage of "Partner_Get" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this PartnerResponseResource created on azure + // for more information of creating PartnerResponseResource, please refer to the document of PartnerResponseResource + string partnerId = "123456"; + ResourceIdentifier partnerResponseResourceId = PartnerResponseResource.CreateResourceIdentifier(partnerId); + PartnerResponseResource partnerResponse = client.GetPartnerResponseResource(partnerResponseResourceId); + + // invoke the operation + PartnerResponseResource result = await partnerResponse.GetAsync(); + + // the variable result is 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}"); + } + + // PatchPartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PatchPartnerDetails() + { + // 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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this PartnerResponseResource created on azure + // for more information of creating PartnerResponseResource, please refer to the document of PartnerResponseResource + string partnerId = "123456"; + ResourceIdentifier partnerResponseResourceId = PartnerResponseResource.CreateResourceIdentifier(partnerId); + PartnerResponseResource partnerResponse = client.GetPartnerResponseResource(partnerResponseResourceId); + + // invoke the operation + PartnerResponseResource result = await partnerResponse.UpdateAsync(); + + // the variable result is 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}"); + } + + // DeletePartnerDetails + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeletePartnerDetails() + { + // 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. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this PartnerResponseResource created on azure + // for more information of creating PartnerResponseResource, please refer to the document of PartnerResponseResource + string partnerId = "123456"; + ResourceIdentifier partnerResponseResourceId = PartnerResponseResource.CreateResourceIdentifier(partnerId); + PartnerResponseResource partnerResponse = client.GetPartnerResponseResource(partnerResponseResourceId); + + // invoke the operation + await partnerResponse.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..d8d78f724eab1 --- /dev/null +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/Generated/Samples/Sample_TenantResourceExtensions.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.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.ManagementPartner.Models; + +namespace Azure.ResourceManager.ManagementPartner +{ + public partial class Sample_TenantResourceExtensions + { + // GetOperations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetOperations_GetOperations() + { + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/GetOperations.json + // this example is just showing the usage of "Operation_List" operation, for the dependent resources, they will have to be created separately. + + // authenticate your client + ArmClient client = new ArmClient(new DefaultAzureCredential()); + + // this example assumes you already have this 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 + await foreach (OperationResponse item in tenantResource.GetOperationsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/autorest.tests.md b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/autorest.tests.md new file mode 100644 index 0000000000000..9d50f4992ba04 --- /dev/null +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/tests/autorest.tests.md @@ -0,0 +1,13 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateTest` to generate code. + +# Azure.ResourceManager.ManagementPartner.Tests + +> see https://aka.ms/autorest +``` yaml +require: ../src/autorest.md +include-x-ms-examples-original-file: true +testgen: + sample: true +``` \ No newline at end of file