From b42ee8f19f7ded7277ead8f5f6a35e5a7ba75b91 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Mon, 3 Jul 2023 18:52:31 +0800 Subject: [PATCH 1/7] generate sample for postgresql --- .../MySql/Custom/Models/MySqlServerVersion.cs | 35 +- .../Generated/Models/MySqlServerVersion.cs | 47 ++ .../Azure.ResourceManager.PostgreSql.sln | 34 +- ....ResourceManager.PostgreSql.Samples.csproj | 10 + .../samples/autorest.tests.md | 13 + ...ample_PostgreSqlConfigurationCollection.cs | 164 +++++ .../Sample_PostgreSqlConfigurationResource.cs | 90 +++ .../Sample_PostgreSqlDatabaseCollection.cs | 164 +++++ .../Sample_PostgreSqlDatabaseResource.cs | 118 ++++ ...Sample_PostgreSqlFirewallRuleCollection.cs | 161 +++++ .../Sample_PostgreSqlFirewallRuleResource.cs | 115 ++++ ...rActiveDirectoryAdministratorCollection.cs | 166 ++++++ ...verActiveDirectoryAdministratorResource.cs | 120 ++++ ...ostgreSqlFlexibleServerBackupCollection.cs | 122 ++++ ..._PostgreSqlFlexibleServerBackupResource.cs | 51 ++ ...mple_PostgreSqlFlexibleServerCollection.cs | 559 ++++++++++++++++++ ...qlFlexibleServerConfigurationCollection.cs | 164 +++++ ...eSqlFlexibleServerConfigurationResource.cs | 90 +++ ...tgreSqlFlexibleServerDatabaseCollection.cs | 164 +++++ ...ostgreSqlFlexibleServerDatabaseResource.cs | 118 ++++ ...SqlFlexibleServerFirewallRuleCollection.cs | 161 +++++ ...reSqlFlexibleServerFirewallRuleResource.cs | 115 ++++ ...Sample_PostgreSqlFlexibleServerResource.cs | 485 +++++++++++++++ ...eSqlPrivateEndpointConnectionCollection.cs | 164 +++++ ...greSqlPrivateEndpointConnectionResource.cs | 123 ++++ .../Sample_PostgreSqlPrivateLinkResource.cs | 51 ++ ...PostgreSqlPrivateLinkResourceCollection.cs | 122 ++++ ...e_PostgreSqlServerAdministratorResource.cs | 118 ++++ .../Sample_PostgreSqlServerCollection.cs | 357 +++++++++++ .../Sample_PostgreSqlServerKeyCollection.cs | 165 ++++++ .../Sample_PostgreSqlServerKeyResource.cs | 119 ++++ .../Sample_PostgreSqlServerResource.cs | 293 +++++++++ ...eSqlServerSecurityAlertPolicyCollection.cs | 217 +++++++ ...greSqlServerSecurityAlertPolicyResource.cs | 140 +++++ ..._PostgreSqlVirtualNetworkRuleCollection.cs | 164 +++++ ...le_PostgreSqlVirtualNetworkRuleResource.cs | 118 ++++ .../Sample_SubscriptionResourceExtensions.cs | 139 +++++ .../Sample_TenantResourceExtensions.cs | 42 ++ .../Models/PostgreSqlMinimalTlsVersionEnum.cs | 37 +- .../Custom/Models/PostgreSqlServerVersion.cs | 40 +- .../Models/PostgreSqlMinimalTlsVersionEnum.cs | 50 ++ .../Models/PostgreSqlServerVersion.cs | 50 ++ .../Models/PostgreSqlFlexibleServerVersion.cs | 37 +- .../Models/PostgreSqlFlexibleServerVersion.cs | 48 ++ 44 files changed, 5717 insertions(+), 143 deletions(-) create mode 100644 sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerVersion.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Azure.ResourceManager.PostgreSql.Samples.csproj create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/autorest.tests.md create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlMinimalTlsVersionEnum.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlServerVersion.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs index 414bc79089bd..ce5aaa289ddf 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs @@ -4,52 +4,23 @@ #nullable disable using System; -using System.ComponentModel; using Azure.Core; -[assembly:CodeGenSuppressType("MySqlServerVersion")] namespace Azure.ResourceManager.MySql.Models { /// The version of a server. public readonly partial struct MySqlServerVersion : IEquatable { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public MySqlServerVersion(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } #pragma warning disable CA1707 - private const string Ver5_6Value = "5.6"; - private const string Ver5_7Value = "5.7"; - private const string Ver8_0Value = "8.0"; - /// 5.6. + [CodeGenMember("FivePointSix")] public static MySqlServerVersion Ver5_6 { get; } = new MySqlServerVersion(Ver5_6Value); /// 5.7. + [CodeGenMember("FivePointSeven")] public static MySqlServerVersion Ver5_7 { get; } = new MySqlServerVersion(Ver5_7Value); /// 8.0. + [CodeGenMember("EightPointZero")] public static MySqlServerVersion Ver8_0 { get; } = new MySqlServerVersion(Ver8_0Value); #pragma warning restore CA1707 - /// Determines if two values are the same. - public static bool operator ==(MySqlServerVersion left, MySqlServerVersion right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MySqlServerVersion left, MySqlServerVersion right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator MySqlServerVersion(string value) => new MySqlServerVersion(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MySqlServerVersion other && Equals(other); - /// - public bool Equals(MySqlServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerVersion.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerVersion.cs new file mode 100644 index 000000000000..081bbb4d9a6f --- /dev/null +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerVersion.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.MySql.Models +{ + /// The version of a server. + public readonly partial struct MySqlServerVersion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MySqlServerVersion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Ver5_6Value = "5.6"; + private const string Ver5_7Value = "5.7"; + private const string Ver8_0Value = "8.0"; + /// Determines if two values are the same. + public static bool operator ==(MySqlServerVersion left, MySqlServerVersion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MySqlServerVersion left, MySqlServerVersion right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MySqlServerVersion(string value) => new MySqlServerVersion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MySqlServerVersion other && Equals(other); + /// + public bool Equals(MySqlServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/Azure.ResourceManager.PostgreSql.sln b/sdk/postgresql/Azure.ResourceManager.PostgreSql/Azure.ResourceManager.PostgreSql.sln index 608e8e33e924..c05781b8f340 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/Azure.ResourceManager.PostgreSql.sln +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/Azure.ResourceManager.PostgreSql.sln @@ -1,19 +1,15 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30309.148 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33801.468 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{C8916C6C-CE14-4A69-BCFE-FFEDA8A137C0}") = "Azure.ResourceManager.PostgreSql", "src\Azure.ResourceManager.PostgreSql.csproj", "{1BA2F101-CA05-4DD8-8EB6-35F0953D76D5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.PostgreSql", "src\Azure.ResourceManager.PostgreSql.csproj", "{1BA2F101-CA05-4DD8-8EB6-35F0953D76D5}" EndProject -Project("{C8916C6C-CE14-4A69-BCFE-FFEDA8A137C0}") = "Azure.ResourceManager.PostgreSql.Tests", "tests\Azure.ResourceManager.PostgreSql.Tests.csproj", "{F86DE6B5-3F93-4344-A8CE-0166A186585D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.PostgreSql.Tests", "tests\Azure.ResourceManager.PostgreSql.Tests.csproj", "{F86DE6B5-3F93-4344-A8CE-0166A186585D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.PostgreSql.Samples", "samples\Azure.ResourceManager.PostgreSql.Samples.csproj", "{5630728D-75C0-426F-8511-7BCABA2F81C4}" EndProject Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B6A1758A-8648-49E5-A900-C809F32ADAFE} - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -47,5 +43,23 @@ Global {F86DE6B5-3F93-4344-A8CE-0166A186585D}.Release|x64.Build.0 = Release|Any CPU {F86DE6B5-3F93-4344-A8CE-0166A186585D}.Release|x86.ActiveCfg = Release|Any CPU {F86DE6B5-3F93-4344-A8CE-0166A186585D}.Release|x86.Build.0 = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|x64.ActiveCfg = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|x64.Build.0 = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|x86.ActiveCfg = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Debug|x86.Build.0 = Debug|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|Any CPU.Build.0 = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|x64.ActiveCfg = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|x64.Build.0 = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|x86.ActiveCfg = Release|Any CPU + {5630728D-75C0-426F-8511-7BCABA2F81C4}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B6A1758A-8648-49E5-A900-C809F32ADAFE} EndGlobalSection EndGlobal diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Azure.ResourceManager.PostgreSql.Samples.csproj b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Azure.ResourceManager.PostgreSql.Samples.csproj new file mode 100644 index 000000000000..76379fc2bebc --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Azure.ResourceManager.PostgreSql.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/autorest.tests.md b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/autorest.tests.md new file mode 100644 index 000000000000..c21001d47d11 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/autorest.tests.md @@ -0,0 +1,13 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateTests` to generate code. + +# Azure.ResourceManager.PostgreSql.Tests + +> see https://aka.ms/autorest +``` yaml +require: ../src/autorest.md +include-x-ms-examples-original-file: true +testgen: + sample: true +``` 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 new file mode 100644 index 000000000000..b1452f449c1a --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlConfigurationCollection + { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() + { + Value = "off", + Source = "user-override", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationResource 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..9f5d42ea4b6f --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationResource.cs @@ -0,0 +1,90 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlConfigurationResource + { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + 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; + + // the variable result is 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}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); + + // invoke the operation + 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 + PostgreSqlConfigurationData 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_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs new file mode 100644 index 000000000000..2b5b7fe205f5 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlDatabaseCollection + { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() + { + Charset = "UTF8", + Collation = "English_United States.1252", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseResource 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // DatabaseList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_DatabaseList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..295a72ca38bf --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlDatabaseResource + { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // DatabaseDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DatabaseDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + await postgreSqlDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlDatabaseData 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_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs new file mode 100644 index 000000000000..9acad1a3bb4f --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlFirewallRuleCollection + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleResource 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..0a5596a5e9a2 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlFirewallRuleResource + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/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 PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFirewallRuleData 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_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs new file mode 100644 index 000000000000..4f25c2b28774 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs @@ -0,0 +1,166 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection + { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() + { + PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, + PrincipalName = "testuser1@microsoft.com", + TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectId, 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 + PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await collection.GetAsync(objectId); + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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); + + // 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); + + Console.WriteLine($"Succeeded: {result}"); + } + + // AdministratorsListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_AdministratorsListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..87d9b6dc29af --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs @@ -0,0 +1,120 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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; + + // the variable result is 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}"); + } + + // AdministratorDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_AdministratorDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorDelete.json + // this example is just showing the usage of "Administrators_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); + + // invoke the operation + await postgreSqlFlexibleServerActiveDirectoryAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..920be98bade4 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerBackupCollection + { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + PostgreSqlFlexibleServerBackupResource result = await collection.GetAsync(backupName); + + // the variable result is 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}"); + } + + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + bool result = await collection.ExistsAsync(backupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List backups for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListBackupsForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..8feb472ea74e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerBackupResource + { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerBackupResource created on azure + // for more information of creating PostgreSqlFlexibleServerBackupResource, please refer to the document of PostgreSqlFlexibleServerBackupResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "postgresqltestserver"; + string backupName = "daily_20210615T160516"; + ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); + PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerBackupData 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_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs new file mode 100644 index 000000000000..6b8e093a3b13 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs @@ -0,0 +1,559 @@ +// 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.Models; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerCollection + { + // Create a database as a geo-restore in geo-paired location + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateGeoRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5geo"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + StorageSizeInGB = 512, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server with active directory authentication enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticationEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithAadAuthEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + StorageSizeInGB = 512, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + { + KeyType = new PostgreSqlFlexibleServerKeyType("SystemManaged"), + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateReplica + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateReplica() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateReplica.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5rep"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.Replica, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithDataEncryptionEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +}, + }, + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + StorageSizeInGB = 512, + 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"), + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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)) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..99d3c556426f --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection + { + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlFlexibleServerConfigurationResource 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 + PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + 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; + + // the variable result is 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 new file mode 100644 index 000000000000..861f0c1098f5 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs @@ -0,0 +1,90 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerConfigurationResource + { + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationResource result = await postgreSqlFlexibleServerConfiguration.GetAsync(); + + // the variable result is 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}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "event_scheduler"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() + { + Value = "on", + Source = "user-override", + }; + ArmOperation lro = await postgreSqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServerConfigurationResource result = lro.Value; + + // the variable result is 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_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs new file mode 100644 index 000000000000..a10714561932 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerDatabaseCollection + { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() + { + Charset = "utf8", + Collation = "en_US.utf8", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseResource 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List databases in a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListDatabasesInAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..504bbf249c4b --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerDatabaseResource + { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // Delete a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + await postgreSqlFlexibleServerDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerDatabaseData 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_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs new file mode 100644 index 000000000000..bbb734fed775 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerFirewallRuleCollection + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleResource 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..659bb4ba5b45 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/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 PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFlexibleServerFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerFirewallRuleData 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_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs new file mode 100644 index 000000000000..52e7c26d76f2 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs @@ -0,0 +1,485 @@ +// 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.Models; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerResource + { + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + StorageSizeInGB = 1024, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithAadAuthEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithAadAuthEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + StorageSizeInGB = 1024, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithCustomerMaintenanceWindow + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() + { + CustomWindow = "Enabled", + StartHour = 8, + StartMinute = 0, + DayOfWeek = 0, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithDataEncryptionEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +}, + }, + AdministratorLoginPassword = "newpassword", + StorageSizeInGB = 1024, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + 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"), + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithMajorVersionUpgrade + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithMajorVersionUpgrade() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithMajorVersionUpgrade.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Version = PostgreSqlFlexibleServerVersion.Ver14, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); + // 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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); + // 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 = "pgtestsvc4"; + 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}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetPostgreSqlFlexibleServers_ServerList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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 (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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // 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.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerRestartWithFailover + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestartWithFailover() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestartWithFailover.json + // this example is just showing the usage of "Servers_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(); + // 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 + PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() + { + RestartWithFailover = true, + FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, + }; + await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed, postgreSqlFlexibleServerRestartParameter: postgreSqlFlexibleServerRestartParameter); + + Console.WriteLine($"Succeeded"); + } + + // ServerStart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Start_ServerStart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStart.json + // this example is just showing the usage of "Servers_Start" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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.StartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerStop + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Stop_ServerStop() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStop.json + // this example is just showing the usage of "Servers_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(); + // 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.StopAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..3d6ac24429fa --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection + { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + PostgreSqlPrivateEndpointConnectionResource 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 + PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Approve or reject a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // 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; + + // the variable result is 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}"); + } + + // Gets list of private endpoint connections on a server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..c69ce8d02e4e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs @@ -0,0 +1,123 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateEndpointConnectionResource + { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionResource result = await postgreSqlPrivateEndpointConnection.GetAsync(); + + // the variable result is 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}"); + } + + // Deletes a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + await postgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Update private endpoint connection Tags + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdatePrivateEndpointConnectionTags() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json + // this example is just showing the usage of "PrivateEndpointConnections_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 PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() + { + Tags = +{ +["key1"] = "val1", +["key2"] = "val2", +["key3"] = "val3", +}, + }; + ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); + 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 + PostgreSqlPrivateEndpointConnectionData 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_PostgreSqlPrivateLinkResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs new file mode 100644 index 000000000000..b6df7e81e6fd --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.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; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateLinkResource + { + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateLinkResource created on azure + // for more information of creating PostgreSqlPrivateLinkResource, please refer to the document of PostgreSqlPrivateLinkResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string groupName = "plr"; + ResourceIdentifier postgreSqlPrivateLinkResourceId = PostgreSqlPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, groupName); + PostgreSqlPrivateLinkResource postgreSqlPrivateLinkResource = client.GetPostgreSqlPrivateLinkResource(postgreSqlPrivateLinkResourceId); + + // invoke the operation + PostgreSqlPrivateLinkResource result = await postgreSqlPrivateLinkResource.GetAsync(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..2ad5a19787e9 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateLinkResourceCollection + { + // Gets private link resources for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + PostgreSqlPrivateLinkResource 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 + PostgreSqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + bool result = await collection.ExistsAsync(groupName); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} 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 new file mode 100644 index 000000000000..92fd03305708 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerAdministratorResource + { + // ServerAdministratorGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerAdministratorGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminGet.json + // this example is just showing the usage of "ServerAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + PostgreSqlServerAdministratorResource result = await postgreSqlServerAdministrator.GetAsync(); + + // the variable result is 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}"); + } + + // ServerAdministratorCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerAdministratorCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + 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; + + // the variable result is 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}"); + } + + // ServerAdministratorsDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerAdministratorsDelete() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..74fbe57fcddd --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerCollection.cs @@ -0,0 +1,357 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerCollection + { + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"), DateTimeOffset.Parse("2017-12-14T00:00:37.467Z")), new AzureLocation("brazilsouth")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 PostgreSqlServerResource + PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForDefaultCreate("cloudsa", "") + { + SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, + MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, + StorageProfile = new PostgreSqlStorageProfile() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, + StorageInMB = 128000, + }, + }, new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a replica server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAReplicaServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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_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 = "testserver-replica1"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForReplica(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")), new AzureLocation("westcentralus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a server as a geo restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForGeoRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")), new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + PostgreSqlServerResource result = await collection.GetAsync(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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // 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(); + // 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 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // 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(); + // 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_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 and iterate over the result + string serverName = "testserver-master"; + await foreach (PostgreSqlServerResource 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 + PostgreSqlServerData 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/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs new file mode 100644 index 000000000000..7aadc6043331 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs @@ -0,0 +1,165 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerKeyCollection + { + // List the keys for a PostgreSQL Server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheKeysForAPostgreSQLServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + PostgreSqlServerKeyResource result = await collection.GetAsync(keyName); + + // the variable result is 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}"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + bool result = await collection.ExistsAsync(keyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // 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; + + // the variable result is 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 new file mode 100644 index 000000000000..dab6192a125b --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyResource.cs @@ -0,0 +1,119 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerKeyResource + { + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + PostgreSqlServerKeyResource result = await postgreSqlServerKey.GetAsync(); + + // the variable result is 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}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + 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; + + // the variable result is 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}"); + } + + // Delete the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteThePostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..ed008efe8e30 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerResource.cs @@ -0,0 +1,293 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerResource + { + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + 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; + + // the variable result is 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; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-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 PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task UpdateConfigurations_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json + // this example is just showing the usage of "ServerParameters_ListUpdateConfigurations" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlConfigurationList value = new PostgreSqlConfigurationList(); + ArmOperation lro = await postgreSqlServer.UpdateConfigurationsAsync(WaitUntil.Completed, value); + PostgreSqlConfigurationList result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + // LogFileList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetLogFiles_LogFileList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/LogFileListByServer.json + // this example is just showing the usage of "LogFiles_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlLogFile item in postgreSqlServer.GetLogFilesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetRecoverableServer_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/RecoverableServersGet.json + // this example is just showing the usage of "RecoverableServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlRecoverableServerResourceData result = await postgreSqlServer.GetRecoverableServerAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // PerformanceTiersList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetServerBasedPerformanceTiers_PerformanceTiersList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json + // this example is just showing the usage of "ServerBasedPerformanceTier_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlPerformanceTierProperties item in postgreSqlServer.GetServerBasedPerformanceTiersAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..fe2ade8a83d3 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs @@ -0,0 +1,217 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection + { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(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}"); + } + + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + bool result = await collection.ExistsAsync(securityAlertPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // 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; + + // the variable result is 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}"); + } + + // List the server's threat detection policies + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheServerSThreatDetectionPolicies() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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}"); + } + + 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 new file mode 100644 index 000000000000..92a7931197a1 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs @@ -0,0 +1,140 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerSecurityAlertPolicyResource + { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyResource result = await postgreSqlServerSecurityAlertPolicy.GetAsync(); + + // the variable result is 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}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + 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 postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + { + State = PostgreSqlServerSecurityAlertPolicyState.Disabled, + SendToEmailAccountAdmins = true, + }; + ArmOperation lro = await postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData 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_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs new file mode 100644 index 000000000000..9a77a4760dff --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlVirtualNetworkRuleCollection + { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(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}"); + } + + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // 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; + + // the variable result is 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}"); + } + + // List virtual network rules + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListVirtualNetworkRules() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..ae16b246c287 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlVirtualNetworkRuleResource + { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + PostgreSqlVirtualNetworkRuleResource result = await postgreSqlVirtualNetworkRule.GetAsync(); + + // the variable result is 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}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + 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; + + // the variable result is 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}"); + } + + // Delete a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..5008306cd38b --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + // CapabilitiesList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteLocationBasedCapabilities_CapabilitiesList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CapabilitiesByLocation.json + // this example is just showing the usage of "LocationBasedCapabilities_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 + AzureLocation locationName = new AzureLocation("westus"); + await foreach (PostgreSqlFlexibleServerCapabilityProperties item in subscriptionResource.ExecuteLocationBasedCapabilitiesAsync(locationName)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // NameAvailability + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckPostgreSqlFlexibleServerNameAvailability_NameAvailability() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailability.json + // this example is just showing the usage of "CheckNameAvailability_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 + PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") + { + ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), + }; + PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // NameAvailability + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_NameAvailability() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailabilityLocationBased.json + // this example is just showing the usage of "CheckNameAvailabilityWithLocation_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 locationName = new AzureLocation("westus"); + PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") + { + ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), + }; + PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityWithLocationAsync(locationName, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // VirtualNetworkSubnetUsageList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/VirtualNetworkSubnetUsage.json + // this example is just showing the usage of "VirtualNetworkSubnetUsage_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 locationName = new AzureLocation("westus"); + PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter = new PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter() + { + VirtualNetworkArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), + }; + PostgreSqlFlexibleServerVirtualNetworkSubnetUsageResult result = await subscriptionResource.ExecuteVirtualNetworkSubnetUsageAsync(locationName, postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} 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 new file mode 100644 index 000000000000..d3e0eb636588 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/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.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_TenantResourceExtensions + { + // GetPrivateDnsZoneSuffix + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/GetPrivateDnsZoneSuffix.json + // this example is just showing the usage of "GetPrivateDnsZoneSuffix_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this 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 result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlMinimalTlsVersionEnum.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlMinimalTlsVersionEnum.cs index 2a11fb88202a..940ef60a967f 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlMinimalTlsVersionEnum.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlMinimalTlsVersionEnum.cs @@ -7,52 +7,21 @@ using System.ComponentModel; using Azure.Core; -[assembly:CodeGenSuppressType("PostgreSqlMinimalTlsVersionEnum")] namespace Azure.ResourceManager.PostgreSql.Models { /// Enforce a minimal Tls version for the server. public readonly partial struct PostgreSqlMinimalTlsVersionEnum : IEquatable { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public PostgreSqlMinimalTlsVersionEnum(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } #pragma warning disable CA1707 - private const string Tls1_0Value = "TLS1_0"; - private const string Tls1_1Value = "TLS1_1"; - private const string Tls1_2Value = "TLS1_2"; - private const string TLSEnforcementDisabledValue = "TLSEnforcementDisabled"; - /// TLS1_0. + [CodeGenMember("TLS10")] public static PostgreSqlMinimalTlsVersionEnum Tls1_0 { get; } = new PostgreSqlMinimalTlsVersionEnum(Tls1_0Value); /// TLS1_1. + [CodeGenMember("TLS11")] public static PostgreSqlMinimalTlsVersionEnum Tls1_1 { get; } = new PostgreSqlMinimalTlsVersionEnum(Tls1_1Value); /// TLS1_2. + [CodeGenMember("TLS12")] public static PostgreSqlMinimalTlsVersionEnum Tls1_2 { get; } = new PostgreSqlMinimalTlsVersionEnum(Tls1_2Value); #pragma warning restore CA1707 - /// TLSEnforcementDisabled. - public static PostgreSqlMinimalTlsVersionEnum TLSEnforcementDisabled { get; } = new PostgreSqlMinimalTlsVersionEnum(TLSEnforcementDisabledValue); - /// Determines if two values are the same. - public static bool operator ==(PostgreSqlMinimalTlsVersionEnum left, PostgreSqlMinimalTlsVersionEnum right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(PostgreSqlMinimalTlsVersionEnum left, PostgreSqlMinimalTlsVersionEnum right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator PostgreSqlMinimalTlsVersionEnum(string value) => new PostgreSqlMinimalTlsVersionEnum(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is PostgreSqlMinimalTlsVersionEnum other && Equals(other); - /// - public bool Equals(PostgreSqlMinimalTlsVersionEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlServerVersion.cs index 1b57d6608b08..1b1a70ef6158 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlServerVersion.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Custom/Models/PostgreSqlServerVersion.cs @@ -7,58 +7,30 @@ using System.ComponentModel; using Azure.Core; -[assembly:CodeGenSuppressType("PostgreSqlServerVersion")] namespace Azure.ResourceManager.PostgreSql.Models { /// The version of a server. public readonly partial struct PostgreSqlServerVersion : IEquatable { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public PostgreSqlServerVersion(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } #pragma warning disable CA1707 - private const string Ver9_5Value = "9.5"; - private const string Ver9_6Value = "9.6"; - private const string Ver10Value = "10"; - private const string Ver10_0Value = "10.0"; - private const string Ver10_2Value = "10.2"; - private const string Ver11Value = "11"; - /// 9.5. + [CodeGenMember("NinePointFive")] public static PostgreSqlServerVersion Ver9_5 { get; } = new PostgreSqlServerVersion(Ver9_5Value); /// 9.6. + [CodeGenMember("NinePointSix")] public static PostgreSqlServerVersion Ver9_6 { get; } = new PostgreSqlServerVersion(Ver9_6Value); /// 10. + [CodeGenMember("Ten")] public static PostgreSqlServerVersion Ver10 { get; } = new PostgreSqlServerVersion(Ver10Value); /// 10.0. + [CodeGenMember("TenPointZero")] public static PostgreSqlServerVersion Ver10_0 { get; } = new PostgreSqlServerVersion(Ver10_0Value); /// 10.2. + [CodeGenMember("TenPointTwo")] public static PostgreSqlServerVersion Ver10_2 { get; } = new PostgreSqlServerVersion(Ver10_2Value); /// 11. + [CodeGenMember("Eleven")] public static PostgreSqlServerVersion Ver11 { get; } = new PostgreSqlServerVersion(Ver11Value); #pragma warning restore CA1707 - /// Determines if two values are the same. - public static bool operator ==(PostgreSqlServerVersion left, PostgreSqlServerVersion right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(PostgreSqlServerVersion left, PostgreSqlServerVersion right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator PostgreSqlServerVersion(string value) => new PostgreSqlServerVersion(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is PostgreSqlServerVersion other && Equals(other); - /// - public bool Equals(PostgreSqlServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlMinimalTlsVersionEnum.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlMinimalTlsVersionEnum.cs new file mode 100644 index 000000000000..3e85a3b2022d --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlMinimalTlsVersionEnum.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.PostgreSql.Models +{ + /// Enforce a minimal Tls version for the server. + public readonly partial struct PostgreSqlMinimalTlsVersionEnum : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PostgreSqlMinimalTlsVersionEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Tls1_0Value = "TLS1_0"; + private const string Tls1_1Value = "TLS1_1"; + private const string Tls1_2Value = "TLS1_2"; + private const string TLSEnforcementDisabledValue = "TLSEnforcementDisabled"; + /// TLSEnforcementDisabled. + public static PostgreSqlMinimalTlsVersionEnum TLSEnforcementDisabled { get; } = new PostgreSqlMinimalTlsVersionEnum(TLSEnforcementDisabledValue); + /// Determines if two values are the same. + public static bool operator ==(PostgreSqlMinimalTlsVersionEnum left, PostgreSqlMinimalTlsVersionEnum right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PostgreSqlMinimalTlsVersionEnum left, PostgreSqlMinimalTlsVersionEnum right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PostgreSqlMinimalTlsVersionEnum(string value) => new PostgreSqlMinimalTlsVersionEnum(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PostgreSqlMinimalTlsVersionEnum other && Equals(other); + /// + public bool Equals(PostgreSqlMinimalTlsVersionEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlServerVersion.cs new file mode 100644 index 000000000000..4e6230fd5a91 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSql/Generated/Models/PostgreSqlServerVersion.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.PostgreSql.Models +{ + /// The version of a server. + public readonly partial struct PostgreSqlServerVersion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PostgreSqlServerVersion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Ver9_5Value = "9.5"; + private const string Ver9_6Value = "9.6"; + private const string Ver10Value = "10"; + private const string Ver10_0Value = "10.0"; + private const string Ver10_2Value = "10.2"; + private const string Ver11Value = "11"; + /// Determines if two values are the same. + public static bool operator ==(PostgreSqlServerVersion left, PostgreSqlServerVersion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PostgreSqlServerVersion left, PostgreSqlServerVersion right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PostgreSqlServerVersion(string value) => new PostgreSqlServerVersion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PostgreSqlServerVersion other && Equals(other); + /// + public bool Equals(PostgreSqlServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs index 9c9293de51fa..b8ef142fa9c9 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs @@ -7,51 +7,22 @@ using System.ComponentModel; using Azure.Core; -[assembly:CodeGenSuppressType("PostgreSqlFlexibleServerVersion")] namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Models { /// The version of a server. public readonly partial struct PostgreSqlFlexibleServerVersion : IEquatable { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public PostgreSqlFlexibleServerVersion(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string Ver14Value = "14"; - private const string Ver13Value = "13"; - private const string Ver12Value = "12"; - private const string Ver11Value = "11"; - /// 14. + [CodeGenMember("Fourteen")] public static PostgreSqlFlexibleServerVersion Ver14 { get; } = new PostgreSqlFlexibleServerVersion(Ver14Value); /// 13. + [CodeGenMember("Thirteen")] public static PostgreSqlFlexibleServerVersion Ver13 { get; } = new PostgreSqlFlexibleServerVersion(Ver13Value); /// 12. + [CodeGenMember("Twelve")] public static PostgreSqlFlexibleServerVersion Ver12 { get; } = new PostgreSqlFlexibleServerVersion(Ver12Value); /// 11. + [CodeGenMember("Eleven")] public static PostgreSqlFlexibleServerVersion Ver11 { get; } = new PostgreSqlFlexibleServerVersion(Ver11Value); - /// Determines if two values are the same. - public static bool operator ==(PostgreSqlFlexibleServerVersion left, PostgreSqlFlexibleServerVersion right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(PostgreSqlFlexibleServerVersion left, PostgreSqlFlexibleServerVersion right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator PostgreSqlFlexibleServerVersion(string value) => new PostgreSqlFlexibleServerVersion(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is PostgreSqlFlexibleServerVersion other && Equals(other); - /// - public bool Equals(PostgreSqlFlexibleServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs new file mode 100644 index 000000000000..783be58e72b2 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Models +{ + /// The version of a server. + public readonly partial struct PostgreSqlFlexibleServerVersion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PostgreSqlFlexibleServerVersion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Ver14Value = "14"; + private const string Ver13Value = "13"; + private const string Ver12Value = "12"; + private const string Ver11Value = "11"; + /// Determines if two values are the same. + public static bool operator ==(PostgreSqlFlexibleServerVersion left, PostgreSqlFlexibleServerVersion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PostgreSqlFlexibleServerVersion left, PostgreSqlFlexibleServerVersion right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PostgreSqlFlexibleServerVersion(string value) => new PostgreSqlFlexibleServerVersion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PostgreSqlFlexibleServerVersion other && Equals(other); + /// + public bool Equals(PostgreSqlFlexibleServerVersion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} From 6b9099db75f0574e91d492ce4382c8e9f1991c0e Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Thu, 20 Jul 2023 18:10:22 +0800 Subject: [PATCH 2/7] update samples --- ...ample_PostgreSqlConfigurationCollection.cs | 143 ----- .../Sample_PostgreSqlConfigurationResource.cs | 69 --- .../Sample_PostgreSqlDatabaseCollection.cs | 143 ----- .../Sample_PostgreSqlDatabaseResource.cs | 97 ---- ...Sample_PostgreSqlFirewallRuleCollection.cs | 139 ----- .../Sample_PostgreSqlFirewallRuleResource.cs | 93 ---- ...rActiveDirectoryAdministratorCollection.cs | 144 ----- ...verActiveDirectoryAdministratorResource.cs | 98 ---- ...ostgreSqlFlexibleServerBackupCollection.cs | 102 ---- ..._PostgreSqlFlexibleServerBackupResource.cs | 31 -- ...mple_PostgreSqlFlexibleServerCollection.cs | 509 +----------------- ...qlFlexibleServerConfigurationCollection.cs | 143 ----- ...eSqlFlexibleServerConfigurationResource.cs | 69 --- ...tgreSqlFlexibleServerDatabaseCollection.cs | 143 ----- ...ostgreSqlFlexibleServerDatabaseResource.cs | 97 ---- ...SqlFlexibleServerFirewallRuleCollection.cs | 139 ----- ...reSqlFlexibleServerFirewallRuleResource.cs | 93 ---- ...Sample_PostgreSqlFlexibleServerResource.cs | 404 ++------------ ...reSqlLtrServerBackupOperationCollection.cs | 122 +++++ ...tgreSqlLtrServerBackupOperationResource.cs | 51 ++ .../Sample_PostgreSqlMigrationCollection.cs | 222 ++++++++ .../Sample_PostgreSqlMigrationResource.cs | 153 ++++++ ...eSqlPrivateEndpointConnectionCollection.cs | 142 ----- ...greSqlPrivateEndpointConnectionResource.cs | 101 ---- .../Sample_PostgreSqlPrivateLinkResource.cs | 31 -- ...PostgreSqlPrivateLinkResourceCollection.cs | 102 ---- ...e_PostgreSqlServerAdministratorResource.cs | 96 ---- .../Sample_PostgreSqlServerCollection.cs | 334 ------------ .../Sample_PostgreSqlServerKeyCollection.cs | 143 ----- .../Sample_PostgreSqlServerKeyResource.cs | 97 ---- .../Sample_PostgreSqlServerResource.cs | 270 ---------- ...eSqlServerSecurityAlertPolicyCollection.cs | 195 ------- ...greSqlServerSecurityAlertPolicyResource.cs | 118 ---- ..._PostgreSqlVirtualNetworkRuleCollection.cs | 143 ----- ...le_PostgreSqlVirtualNetworkRuleResource.cs | 97 ---- .../Sample_SubscriptionResourceExtensions.cs | 8 +- .../Sample_TenantResourceExtensions.cs | 22 - 37 files changed, 604 insertions(+), 4499 deletions(-) create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationResource.cs 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 b1452f449c1a..8a2cf78b4d0b 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 @@ -17,148 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlConfigurationCollection { - // ConfigurationCreateOrUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() - { - Value = "off", - Source = "user-override", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, 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 - PostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlConfigurationResource 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 - PostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ConfigurationList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } } } 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 9f5d42ea4b6f..f8deb88d4790 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,74 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlConfigurationResource { - // ConfigurationCreateOrUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ConfigurationCreateOrUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlConfigurationResource created on azure - // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - 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; - - // the variable result is 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}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlConfigurationResource created on azure - // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); - - // invoke the operation - 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 - PostgreSqlConfigurationData 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_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs index 2b5b7fe205f5..1c601ee370b9 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 @@ -17,148 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlDatabaseCollection { - // DatabaseCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_DatabaseCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() - { - Charset = "UTF8", - Collation = "English_United States.1252", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 - PostgreSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlDatabaseResource 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 - PostgreSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // DatabaseList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_DatabaseList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } } } 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 295a72ca38bf..9b652e900ee1 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,102 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlDatabaseResource { - // DatabaseCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_DatabaseCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - 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; - - // the variable result is 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}"); - } - - // DatabaseDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DatabaseDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseDelete.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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); - - // invoke the operation - await postgreSqlDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); - - // invoke the operation - 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 - PostgreSqlDatabaseData 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_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs index 9acad1a3bb4f..e695e26bf262 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 @@ -18,144 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlFirewallRuleCollection { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_FirewallRuleCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 - PostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFirewallRuleResource 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 - PostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_FirewallRuleList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } } } 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 0a5596a5e9a2..341897fd71a7 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,98 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlFirewallRuleResource { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_FirewallRuleCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - 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; - - // the variable result is 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}"); - } - - // FirewallRuleDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_FirewallRuleDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/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 PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); - - // invoke the operation - await postgreSqlFirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); - - // invoke the operation - 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 - PostgreSqlFirewallRuleData 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_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs index 4f25c2b28774..2ae67ae24b98 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 @@ -18,149 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection { - // Adds an Active DIrectory Administrator for the server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource - PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - - // invoke the operation - string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() - { - PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, - PrincipalName = "testuser1@microsoft.com", - TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectId, 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 - PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource - PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - - // invoke the operation - string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await collection.GetAsync(objectId); - - // the variable result is 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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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); - - // 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); - - Console.WriteLine($"Succeeded: {result}"); - } - - // AdministratorsListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_AdministratorsListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } } } 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 87d9b6dc29af..ada68b45a314 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,103 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource { - // Adds an Active DIrectory Administrator for the server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 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; - - // the variable result is 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}"); - } - - // AdministratorDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_AdministratorDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorDelete.json - // this example is just showing the usage of "Administrators_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); - - // invoke the operation - await postgreSqlFlexibleServerActiveDirectoryAdministrator.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 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(); - - // the variable result is 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}"); - } } } 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 920be98bade4..82cf56887b18 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 @@ -16,107 +16,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerBackupCollection { - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerBackupResource - PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - - // invoke the operation - string backupName = "daily_20210615T160516"; - PostgreSqlFlexibleServerBackupResource result = await collection.GetAsync(backupName); - - // the variable result is 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}"); - } - - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerBackupResource - PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - - // invoke the operation - string backupName = "daily_20210615T160516"; - bool result = await collection.ExistsAsync(backupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // List backups for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListBackupsForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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()) - { - // the variable item is 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"); - } } } 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 8feb472ea74e..cfee18e84ad2 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 @@ -16,36 +16,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerBackupResource { - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerBackupResource created on azure - // for more information of creating PostgreSqlFlexibleServerBackupResource, please refer to the document of PostgreSqlFlexibleServerBackupResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "postgresqltestserver"; - string backupName = "daily_20210615T160516"; - ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); - PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerBackupData 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_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs index 6b8e093a3b13..65202e60c66f 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 @@ -20,12 +20,12 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerCollection { - // Create a database as a geo-restore in geo-paired location + // ServerCreateReviveDropped [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation() + public async Task CreateOrUpdate_ServerCreateReviveDropped() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateGeoRestore.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReviveDropped.json // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -44,53 +44,12 @@ public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc5geo"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus")) - { - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // Create a database as a point in time restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreatePointInTimeRestore.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5"; + string serverName = "pgtestsvc5-rev"; PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) { - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore, + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc5"), + PointInTimeUtc = DateTimeOffset.Parse("2023-04-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.ReviveDropped, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); PostgreSqlFlexibleServerResource result = lro.Value; @@ -101,459 +60,5 @@ public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - // Create a new server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreate.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLogin = "cloudsa", - AdministratorLoginPassword = "password", - Version = PostgreSqlFlexibleServerVersion.Ver12, - StorageSizeInGB = 512, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // Create a new server with active directory authentication enabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticationEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithAadAuthEnabled.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLogin = "cloudsa", - AdministratorLoginPassword = "password", - Version = PostgreSqlFlexibleServerVersion.Ver12, - StorageSizeInGB = 512, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() - { - ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, - PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, - TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() - { - KeyType = new PostgreSqlFlexibleServerKeyType("SystemManaged"), - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerCreateReplica - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerCreateReplica() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateReplica.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5rep"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.Replica, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerCreateWithDataEncryptionEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithDataEncryptionEnabled.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), -}, - }, - AdministratorLogin = "cloudsa", - AdministratorLoginPassword = "password", - Version = PostgreSqlFlexibleServerVersion.Ver12, - StorageSizeInGB = 512, - 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"), - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc1"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerGetWithVnet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGetWithVnet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); - } - - // ServerGetWithVnet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGetWithVnet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerListByResourceGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ServerListByResourceGroup() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // 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()) - { - // the variable item is 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"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetReplicas_ReplicasListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // 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)) - { - // the variable item is 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"); - } } } 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 99d3c556426f..69bff5b74b08 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,148 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection { - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ConfigurationList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlFlexibleServerConfigurationResource 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 - PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Update a user configuration - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAUserConfiguration() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - 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; - - // the variable result is 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 861f0c1098f5..9018afe4dd07 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 @@ -17,74 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerConfigurationResource { - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure - // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); - - // invoke the operation - PostgreSqlFlexibleServerConfigurationResource result = await postgreSqlFlexibleServerConfiguration.GetAsync(); - - // the variable result is 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}"); - } - - // Update a user configuration - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAUserConfiguration() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure - // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string configurationName = "event_scheduler"; - ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); - - // invoke the operation - PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() - { - Value = "on", - Source = "user-override", - }; - ArmOperation lro = await postgreSqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFlexibleServerConfigurationResource result = lro.Value; - - // the variable result is 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_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs index a10714561932..cfb9845a0686 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 @@ -17,148 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerDatabaseCollection { - // Create a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() - { - Charset = "utf8", - Collation = "en_US.utf8", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 - PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlFlexibleServerDatabaseResource 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 - PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // List databases in a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListDatabasesInAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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()) - { - // the variable item is 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"); - } } } 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 504bbf249c4b..b23e240b2f86 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,102 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerDatabaseResource { - // Create a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - 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; - - // the variable result is 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}"); - } - - // Delete a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabaseDelete.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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); - - // invoke the operation - await postgreSqlFlexibleServerDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerDatabaseData 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_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs index bbb734fed775..2fed141791e4 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 @@ -18,144 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerFirewallRuleCollection { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_FirewallRuleCreate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 - PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFlexibleServerFirewallRuleResource 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 - PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } } } 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 659bb4ba5b45..f73a71ec67c2 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,98 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_FirewallRuleCreate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - 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; - - // the variable result is 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}"); - } - - // FirewallRuleDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_FirewallRuleDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/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 PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); - - // invoke the operation - await postgreSqlFlexibleServerFirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerFirewallRuleData 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_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs index 52e7c26d76f2..d5389c8b6e14 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 @@ -20,204 +20,13 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerResource { - // ServerUpdate + // ServerCapabilitiesList [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdate() + public async Task GetServerCapabilities_ServerCapabilitiesList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLoginPassword = "newpassword", - StorageSizeInGB = 1024, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithAadAuthEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithAadAuthEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLoginPassword = "newpassword", - StorageSizeInGB = 1024, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() - { - ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, - PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, - TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithCustomerMaintenanceWindow - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.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(); - // 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 = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() - { - CustomWindow = "Enabled", - StartHour = 8, - StartMinute = 0, - DayOfWeek = 0, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithDataEncryptionEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithDataEncryptionEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithDataEncryptionEnabled.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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), -}, - }, - AdministratorLoginPassword = "newpassword", - StorageSizeInGB = 1024, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - 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"), - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithMajorVersionUpgrade - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithMajorVersionUpgrade() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithMajorVersionUpgrade.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/preview/2023-03-01-preview/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(); @@ -232,56 +41,22 @@ public async Task Update_ServerUpdateWithMajorVersionUpgrade() ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerCapabilityProperties item in postgreSqlFlexibleServer.GetServerCapabilitiesAsync()) { - Version = PostgreSqlFlexibleServerVersion.Ver14, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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: {item}"); + } Console.WriteLine($"Succeeded"); } - // ServerGet + // CheckMigrationNameAvailability [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() + public async Task CheckPostgreSqlMigrationNameAvailability_CheckMigrationNameAvailability() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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/preview/2023-03-01-preview/examples/CheckMigrationNameAvailability.json + // this example is just showing the usage of "CheckMigrationNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK 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,27 +67,24 @@ public async Task Get_ServerGet() // 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); + string targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); + PostgreSqlCheckMigrationNameAvailabilityContent content = new PostgreSqlCheckMigrationNameAvailabilityContent("name1", new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers/migrations")); + PostgreSqlCheckMigrationNameAvailabilityContent result = await postgreSqlFlexibleServer.CheckPostgreSqlMigrationNameAvailabilityAsync(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 - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } - // ServerGetWithVnet + // List all server log files for a server [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGetWithVnet() + public async Task GetPostgreSqlFlexibleServerLogFiles_ListAllServerLogFilesForAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-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/preview/2023-03-01-preview/examples/LogFilesListByServer.json + // this example is just showing the usage of "LogFiles_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(); @@ -323,59 +95,26 @@ public async Task Get_ServerGetWithVnet() // 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 = "pgtestsvc4"; + string serverName = "postgresqltestsvc1"; 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}"); - } - - // ServerList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetPostgreSqlFlexibleServers_ServerList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-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 (PostgreSqlFlexibleServerResource item in subscriptionResource.GetPostgreSqlFlexibleServersAsync()) + await foreach (PostgreSqlFlexibleServerLogFile item in postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerLogFilesAsync()) { - // the variable item is 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"); } - // ServerRestart + // Sample_Prebackup [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestart() + public async Task TriggerLtrPreBackupFlexibleServer_SamplePrebackup() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestart.json - // this example is just showing the usage of "Servers_Restart" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionPreBackup.json + // this example is just showing the usage of "FlexibleServer_TriggerLtrPreBackup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK 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,24 +124,25 @@ public async Task Restart_ServerRestart() // 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"; + string resourceGroupName = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed); + PostgreSqlFlexibleServerLtrPreBackupContent content = new PostgreSqlFlexibleServerLtrPreBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1")); + PostgreSqlFlexibleServerLtrPreBackupResult result = await postgreSqlFlexibleServer.TriggerLtrPreBackupFlexibleServerAsync(content); - Console.WriteLine($"Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } - // ServerRestartWithFailover + // Sample_ExecuteBackup [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestartWithFailover() + public async Task StartLtrBackupFlexibleServer_SampleExecuteBackup() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestartWithFailover.json - // this example is just showing the usage of "Servers_Restart" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionBackup.json + // this example is just showing the usage of "FlexibleServer_StartLtrBackup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK 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,74 +152,20 @@ public async Task Restart_ServerRestartWithFailover() // 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"; + string resourceGroupName = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() + PostgreSqlFlexibleServerLtrBackupContent content = new PostgreSqlFlexibleServerLtrBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1"), new PostgreSqlFlexibleServerBackupStoreDetails(new string[] { - RestartWithFailover = true, - FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, - }; - await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed, postgreSqlFlexibleServerRestartParameter: postgreSqlFlexibleServerRestartParameter); +"sasuri" + })); + ArmOperation lro = await postgreSqlFlexibleServer.StartLtrBackupFlexibleServerAsync(WaitUntil.Completed, content); + PostgreSqlFlexibleServerLtrBackupResult result = lro.Value; - Console.WriteLine($"Succeeded"); - } - - // ServerStart - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Start_ServerStart() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStart.json - // this example is just showing the usage of "Servers_Start" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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.StartAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerStop - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Stop_ServerStop() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStop.json - // this example is just showing the usage of "Servers_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(); - // 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.StopAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } 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 new file mode 100644 index 000000000000..a2769c985b45 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlLtrServerBackupOperationCollection + { + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlLtrServerBackupOperationResource + PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); + + // invoke the operation + string backupName = "backup1"; + PostgreSqlLtrServerBackupOperationResource result = await collection.GetAsync(backupName); + + // the variable result is 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}"); + } + + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlLtrServerBackupOperationResource + PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); + + // invoke the operation + string backupName = "backup1"; + bool result = await collection.ExistsAsync(backupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Sample List of Long Tern Retention Operations by Flexible Server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs new file mode 100644 index 000000000000..740f0e8d51b8 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlLtrServerBackupOperationResource + { + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlLtrServerBackupOperationResource created on azure + // for more information of creating PostgreSqlLtrServerBackupOperationResource, please refer to the document of PostgreSqlLtrServerBackupOperationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + string backupName = "backup1"; + ResourceIdentifier postgreSqlLtrServerBackupOperationResourceId = PostgreSqlLtrServerBackupOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); + PostgreSqlLtrServerBackupOperationResource postgreSqlLtrServerBackupOperation = client.GetPostgreSqlLtrServerBackupOperationResource(postgreSqlLtrServerBackupOperationResourceId); + + // invoke the operation + PostgreSqlLtrServerBackupOperationResource result = await postgreSqlLtrServerBackupOperation.GetAsync(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..f95efbe08309 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationCollection.cs @@ -0,0 +1,222 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlMigrationCollection + { + // Migrations Create by passing user names + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_MigrationsCreateByPassingUserNames() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create_With_Other_Users.json + // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) + { + 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")) + { + SourceServerUsername = "newadmin@testsource", + TargetServerUsername = "targetadmin", + }, + DbsToMigrate = +{ +"db1","db2","db3","db4" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); + PostgreSqlMigrationResource result = lro.Value; + + // the variable result is 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}"); + } + + // Migrations_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_MigrationsCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create.json + // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) + { + 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" +}, + OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); + PostgreSqlMigrationResource result = lro.Value; + + // the variable result is 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}"); + } + + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationResource result = await collection.GetAsync(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}"); + } + + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + bool result = await collection.ExistsAsync(migrationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Migrations_ListByTargetServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_MigrationsListByTargetServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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)) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..9a77beeed9e7 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationResource.cs @@ -0,0 +1,153 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlMigrationResource + { + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationResource result = await postgreSqlMigration.GetAsync(); + + // the variable result is 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}"); + } + + // Cancel migration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CancelMigration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() + { + Cancel = PostgreSqlMigrationCancel.True, + }; + PostgreSqlMigrationResource result = await postgreSqlMigration.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 + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Migrations_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_MigrationsUpdate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() + { + SetupLogicalReplicationOnSourceDbIfNeeded = PostgreSqlMigrationLogicalReplicationOnSourceDb.True, + }; + PostgreSqlMigrationResource result = await postgreSqlMigration.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 + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Migrations_Delete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_MigrationsDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + await postgreSqlMigration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 3d6ac24429fa..aa24818fdb52 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,147 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection { - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - PostgreSqlPrivateEndpointConnectionResource 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 - PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Approve or reject a private endpoint connection with a given name. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // 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; - - // the variable result is 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}"); - } - - // Gets list of private endpoint connections on a server. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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; - // 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 c69ce8d02e4e..bf80aeab8c24 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 @@ -18,106 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateEndpointConnectionResource { - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - PostgreSqlPrivateEndpointConnectionResource result = await postgreSqlPrivateEndpointConnection.GetAsync(); - - // the variable result is 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}"); - } - - // Deletes a private endpoint connection with a given name. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - await postgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Update private endpoint connection Tags - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdatePrivateEndpointConnectionTags() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json - // this example is just showing the usage of "PrivateEndpointConnections_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 PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() - { - Tags = -{ -["key1"] = "val1", -["key2"] = "val2", -["key3"] = "val3", -}, - }; - ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); - 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 - PostgreSqlPrivateEndpointConnectionData 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_PostgreSqlPrivateLinkResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs index b6df7e81e6fd..93f07a725eaa 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs @@ -16,36 +16,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateLinkResource { - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateLinkResource created on azure - // for more information of creating PostgreSqlPrivateLinkResource, please refer to the document of PostgreSqlPrivateLinkResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string groupName = "plr"; - ResourceIdentifier postgreSqlPrivateLinkResourceId = PostgreSqlPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, groupName); - PostgreSqlPrivateLinkResource postgreSqlPrivateLinkResource = client.GetPostgreSqlPrivateLinkResource(postgreSqlPrivateLinkResourceId); - - // invoke the operation - PostgreSqlPrivateLinkResource result = await postgreSqlPrivateLinkResource.GetAsync(); - - // the variable result is 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}"); - } } } 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 2ad5a19787e9..28a4bd65bf16 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 @@ -16,107 +16,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateLinkResourceCollection { - // Gets private link resources for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateLinkResource - PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - - // invoke the operation - string groupName = "plr"; - PostgreSqlPrivateLinkResource 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 - PostgreSqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateLinkResource - PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - - // invoke the operation - string groupName = "plr"; - bool result = await collection.ExistsAsync(groupName); - - Console.WriteLine($"Succeeded: {result}"); - } } } 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 92fd03305708..6452e478356e 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 @@ -18,101 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerAdministratorResource { - // ServerAdministratorGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerAdministratorGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminGet.json - // this example is just showing the usage of "ServerAdministrators_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); - - // invoke the operation - PostgreSqlServerAdministratorResource result = await postgreSqlServerAdministrator.GetAsync(); - - // the variable result is 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}"); - } - - // ServerAdministratorCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerAdministratorCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - 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; - - // the variable result is 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}"); - } - - // ServerAdministratorsDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerAdministratorsDelete() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); - - // invoke the operation - await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } } } 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 74fbe57fcddd..cd9f805c856a 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 @@ -19,339 +19,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerCollection { - // Create a database as a point in time restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; - 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 = "targetserver"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"), DateTimeOffset.Parse("2017-12-14T00:00:37.467Z")), new AzureLocation("brazilsouth")) - { - Sku = new PostgreSqlSku("B_Gen5_2") - { - Tier = PostgreSqlSkuTier.Basic, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a new server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreate.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 PostgreSqlServerResource - PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForDefaultCreate("cloudsa", "") - { - SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, - MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, - StorageProfile = new PostgreSqlStorageProfile() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, - StorageInMB = 128000, - }, - }, new AzureLocation("westus")) - { - Sku = new PostgreSqlSku("B_Gen5_2") - { - Tier = PostgreSqlSkuTier.Basic, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a replica server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAReplicaServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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_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 = "testserver-replica1"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForReplica(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")), new AzureLocation("westcentralus")) - { - Sku = new PostgreSqlSku("GP_Gen5_2") - { - Tier = PostgreSqlSkuTier.GeneralPurpose, - Capacity = 2, - Family = "Gen5", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a server as a geo restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; - 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 = "targetserver"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForGeoRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")), new AzureLocation("westus")) - { - Sku = new PostgreSqlSku("GP_Gen5_2") - { - Tier = PostgreSqlSkuTier.GeneralPurpose, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // 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(); - // 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 = "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 - string serverName = "pgtestsvc1"; - PostgreSqlServerResource result = await collection.GetAsync(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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // 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(); - // 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 = "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 - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerListByResourceGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ServerListByResourceGroup() - { - // 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(); - // 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 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}"); - } - - Console.WriteLine($"Succeeded"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetReplicas_ReplicasListByServer() - { - // 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(); - // 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_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 and iterate over the result - string serverName = "testserver-master"; - await foreach (PostgreSqlServerResource 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 - PostgreSqlServerData 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/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs index 7aadc6043331..0dc653d88da7 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,148 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerKeyCollection { - // List the keys for a PostgreSQL Server. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListTheKeysForAPostgreSQLServer() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - PostgreSqlServerKeyResource result = await collection.GetAsync(keyName); - - // the variable result is 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}"); - } - - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Creates or updates a PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // 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; - - // the variable result is 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 dab6192a125b..59ff5bf09076 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 @@ -18,102 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerKeyResource { - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); - - // invoke the operation - PostgreSqlServerKeyResource result = await postgreSqlServerKey.GetAsync(); - - // the variable result is 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}"); - } - - // Creates or updates a PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - 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; - - // the variable result is 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}"); - } - - // Delete the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteThePostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); - - // invoke the operation - await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } } } 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 ed008efe8e30..1e5a3525028b 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 @@ -19,275 +19,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerResource { - // ServerUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - 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; - - // the variable result is 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; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-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 PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - await postgreSqlServer.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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"); - } - - // ServerRestart - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestart() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerRestart.json - // this example is just showing the usage of "Servers_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - await postgreSqlServer.RestartAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task UpdateConfigurations_ConfigurationList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json - // this example is just showing the usage of "ServerParameters_ListUpdateConfigurations" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - PostgreSqlConfigurationList value = new PostgreSqlConfigurationList(); - ArmOperation lro = await postgreSqlServer.UpdateConfigurationsAsync(WaitUntil.Completed, value); - PostgreSqlConfigurationList result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - // LogFileList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetLogFiles_LogFileList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/LogFileListByServer.json - // this example is just showing the usage of "LogFiles_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlLogFile item in postgreSqlServer.GetLogFilesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetRecoverableServer_ReplicasListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/RecoverableServersGet.json - // this example is just showing the usage of "RecoverableServers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - PostgreSqlRecoverableServerResourceData result = await postgreSqlServer.GetRecoverableServerAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - - // PerformanceTiersList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetServerBasedPerformanceTiers_PerformanceTiersList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json - // this example is just showing the usage of "ServerBasedPerformanceTier_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlPerformanceTierProperties item in postgreSqlServer.GetServerBasedPerformanceTiersAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } } } 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 fe2ade8a83d3..f09451d8708e 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,200 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection { - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(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}"); - } - - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Update a server's threat detection policy with all parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - 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 - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a server's threat detection policy with minimal parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // 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; - - // the variable result is 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}"); - } - - // List the server's threat detection policies - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListTheServerSThreatDetectionPolicies() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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}"); - } - - 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 92a7931197a1..96c2be64fd9c 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 @@ -18,123 +18,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerSecurityAlertPolicyResource { - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - PostgreSqlServerSecurityAlertPolicyResource result = await postgreSqlServerSecurityAlertPolicy.GetAsync(); - - // the variable result is 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}"); - } - - // Update a server's threat detection policy with all parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - 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 postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a server's threat detection policy with minimal parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() - { - State = PostgreSqlServerSecurityAlertPolicyState.Disabled, - SendToEmailAccountAdmins = true, - }; - ArmOperation lro = await postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 - PostgreSqlServerSecurityAlertPolicyData 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_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs index 9a77a4760dff..8c11026522d9 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,148 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlVirtualNetworkRuleCollection { - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(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}"); - } - - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - bool result = await collection.ExistsAsync(virtualNetworkRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Create or update a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // 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; - - // the variable result is 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}"); - } - - // List virtual network rules - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListVirtualNetworkRules() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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; - // 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 ae16b246c287..d1d4bf362679 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 @@ -17,102 +17,5 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlVirtualNetworkRuleResource { - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); - - // invoke the operation - PostgreSqlVirtualNetworkRuleResource result = await postgreSqlVirtualNetworkRule.GetAsync(); - - // the variable result is 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}"); - } - - // Create or update a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - 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; - - // the variable result is 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}"); - } - - // Delete a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); - - // invoke the operation - await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } } } 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 5008306cd38b..4af48973f373 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 @@ -23,7 +23,7 @@ public partial class Sample_SubscriptionResourceExtensions [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task ExecuteLocationBasedCapabilities_CapabilitiesList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CapabilitiesByLocation.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CapabilitiesByLocation.json // this example is just showing the usage of "LocationBasedCapabilities_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 @@ -52,7 +52,7 @@ public async Task ExecuteLocationBasedCapabilities_CapabilitiesList() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckPostgreSqlFlexibleServerNameAvailability_NameAvailability() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailability.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailability.json // this example is just showing the usage of "CheckNameAvailability_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 @@ -81,7 +81,7 @@ public async Task CheckPostgreSqlFlexibleServerNameAvailability_NameAvailability [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_NameAvailability() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailabilityLocationBased.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailabilityLocationBased.json // this example is just showing the usage of "CheckNameAvailabilityWithLocation_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 @@ -111,7 +111,7 @@ public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_Name [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/VirtualNetworkSubnetUsage.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/VirtualNetworkSubnetUsage.json // this example is just showing the usage of "VirtualNetworkSubnetUsage_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 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 d3e0eb636588..2cebfb8f37fe 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 @@ -16,27 +16,5 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_TenantResourceExtensions { - // GetPrivateDnsZoneSuffix - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/GetPrivateDnsZoneSuffix.json - // this example is just showing the usage of "GetPrivateDnsZoneSuffix_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this 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 result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } } } From 17bc2a1cefcf74950c1b45b5aa24c89a338b6ce4 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Thu, 20 Jul 2023 18:49:33 +0800 Subject: [PATCH 3/7] update samples --- ...ample_PostgreSqlConfigurationCollection.cs | 143 +++++ .../Sample_PostgreSqlConfigurationResource.cs | 69 +++ .../Sample_PostgreSqlDatabaseCollection.cs | 143 +++++ .../Sample_PostgreSqlDatabaseResource.cs | 97 +++ ...Sample_PostgreSqlFirewallRuleCollection.cs | 139 +++++ .../Sample_PostgreSqlFirewallRuleResource.cs | 93 +++ ...rActiveDirectoryAdministratorCollection.cs | 144 +++++ ...verActiveDirectoryAdministratorResource.cs | 98 +++ ...ostgreSqlFlexibleServerBackupCollection.cs | 102 +++ ..._PostgreSqlFlexibleServerBackupResource.cs | 31 + ...mple_PostgreSqlFlexibleServerCollection.cs | 583 ++++++++++++++++++ ...qlFlexibleServerConfigurationCollection.cs | 143 +++++ ...eSqlFlexibleServerConfigurationResource.cs | 69 +++ ...tgreSqlFlexibleServerDatabaseCollection.cs | 143 +++++ ...ostgreSqlFlexibleServerDatabaseResource.cs | 97 +++ ...SqlFlexibleServerFirewallRuleCollection.cs | 139 +++++ ...reSqlFlexibleServerFirewallRuleResource.cs | 93 +++ ...Sample_PostgreSqlFlexibleServerResource.cs | 474 ++++++++++++++ ...eSqlPrivateEndpointConnectionCollection.cs | 142 +++++ ...greSqlPrivateEndpointConnectionResource.cs | 101 +++ .../Sample_PostgreSqlPrivateLinkResource.cs | 31 + ...PostgreSqlPrivateLinkResourceCollection.cs | 102 +++ ...e_PostgreSqlServerAdministratorResource.cs | 96 +++ .../Sample_PostgreSqlServerCollection.cs | 334 ++++++++++ .../Sample_PostgreSqlServerKeyCollection.cs | 143 +++++ .../Sample_PostgreSqlServerKeyResource.cs | 97 +++ .../Sample_PostgreSqlServerResource.cs | 270 ++++++++ ...eSqlServerSecurityAlertPolicyCollection.cs | 195 ++++++ ...greSqlServerSecurityAlertPolicyResource.cs | 118 ++++ ..._PostgreSqlVirtualNetworkRuleCollection.cs | 143 +++++ ...le_PostgreSqlVirtualNetworkRuleResource.cs | 97 +++ .../Sample_TenantResourceExtensions.cs | 22 + 32 files changed, 4691 insertions(+) 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 8a2cf78b4d0b..b1452f449c1a 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 @@ -17,5 +17,148 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlConfigurationCollection { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() + { + Value = "off", + Source = "user-override", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationResource 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } } } 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 f8deb88d4790..9f5d42ea4b6f 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,5 +17,74 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlConfigurationResource { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + 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; + + // the variable result is 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}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); + + // invoke the operation + 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 + PostgreSqlConfigurationData 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_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs index 1c601ee370b9..2b5b7fe205f5 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 @@ -17,5 +17,148 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlDatabaseCollection { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() + { + Charset = "UTF8", + Collation = "English_United States.1252", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseResource 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // DatabaseList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_DatabaseList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } } } 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 9b652e900ee1..295a72ca38bf 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,5 +17,102 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlDatabaseResource { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // DatabaseDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DatabaseDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + await postgreSqlDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlDatabaseData 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_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs index e695e26bf262..9acad1a3bb4f 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 @@ -18,5 +18,144 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlFirewallRuleCollection { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleResource 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } } } 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 341897fd71a7..0a5596a5e9a2 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,5 +18,98 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlFirewallRuleResource { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/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 PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFirewallRuleData 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_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs index 2ae67ae24b98..6c4f9cbb456e 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 @@ -18,5 +18,149 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() + { + PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, + PrincipalName = "testuser1@microsoft.com", + TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectId, 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 + PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await collection.GetAsync(objectId); + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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); + + Console.WriteLine($"Succeeded: {result}"); + } + + // AdministratorsListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_AdministratorsListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } } } 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 ada68b45a314..9fc3b57b010b 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,5 +18,103 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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; + + // the variable result is 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}"); + } + + // AdministratorDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_AdministratorDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/AdministratorDelete.json + // this example is just showing the usage of "Administrators_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); + + // invoke the operation + await postgreSqlFlexibleServerActiveDirectoryAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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(); + + // the variable result is 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}"); + } } } 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 82cf56887b18..6f1dc8d67033 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 @@ -16,5 +16,107 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerBackupCollection { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + PostgreSqlFlexibleServerBackupResource result = await collection.GetAsync(backupName); + + // the variable result is 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}"); + } + + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + bool result = await collection.ExistsAsync(backupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List backups for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListBackupsForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } } } 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 cfee18e84ad2..63e2ef95d7a2 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 @@ -16,5 +16,36 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerBackupResource { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerBackupResource created on azure + // for more information of creating PostgreSqlFlexibleServerBackupResource, please refer to the document of PostgreSqlFlexibleServerBackupResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "postgresqltestserver"; + string backupName = "daily_20210615T160516"; + ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); + PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerBackupData 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_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs index 65202e60c66f..51fa2c1c2a41 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 @@ -20,6 +20,306 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerCollection { + // Create a database as a geo-restore in geo-paired location + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateGeoRestoreWithDataEncryptionEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5geo"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus")) + { + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + 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(), +}, + }, + 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"), + GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), + GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P20, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server with active directory authentication enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticationEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithAadAuthEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P20, + }, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + { + KeyType = PostgreSqlFlexibleServerKeyType.SystemManaged, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateReplica + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateReplica() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReplica.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5rep"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +}, + }, + 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"), + GeoBackupKeyUri = new Uri(""), + GeoBackupUserAssignedIdentityId = "", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.Replica, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + // ServerCreateReviveDropped [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] @@ -60,5 +360,288 @@ public async Task CreateOrUpdate_ServerCreateReviveDropped() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + // ServerCreateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithDataEncryptionEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/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() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + }, + 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"), + GeoBackupKeyUri = new Uri(""), + GeoBackupUserAssignedIdentityId = "", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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)) + { + // the variable item is 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"); + } } } 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 69bff5b74b08..fce6949afb5e 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,5 +17,148 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection { + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlFlexibleServerConfigurationResource 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 + PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + 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; + + // the variable result is 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 9018afe4dd07..4f46abf4d161 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 @@ -17,5 +17,74 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerConfigurationResource { + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationResource result = await postgreSqlFlexibleServerConfiguration.GetAsync(); + + // the variable result is 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}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "event_scheduler"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() + { + Value = "on", + Source = "user-override", + }; + ArmOperation lro = await postgreSqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServerConfigurationResource result = lro.Value; + + // the variable result is 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_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs index cfb9845a0686..06adde43546c 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 @@ -17,5 +17,148 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerDatabaseCollection { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() + { + Charset = "utf8", + Collation = "en_US.utf8", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseResource 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List databases in a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListDatabasesInAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } } } 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 b23e240b2f86..41c9b31286ab 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,5 +17,102 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerDatabaseResource { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // Delete a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + await postgreSqlFlexibleServerDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerDatabaseData 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_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs index 2fed141791e4..de5714383984 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 @@ -18,5 +18,144 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerFirewallRuleCollection { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleResource 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } } } 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 f73a71ec67c2..3a12ebab4a88 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,5 +18,98 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFlexibleServerFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerFirewallRuleData 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_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs index d5389c8b6e14..8428494bd42e 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 @@ -50,6 +50,480 @@ public async Task GetServerCapabilities_ServerCapabilitiesList() Console.WriteLine($"Succeeded"); } + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 1024, + AutoGrow = StorageAutoGrow.Enabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P30, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithAadAuthEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithAadAuthEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithAadAuthEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 1024, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P30, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithCustomerMaintenanceWindow + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() + { + CustomWindow = "Enabled", + StartHour = 8, + StartMinute = 0, + DayOfWeek = 0, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithDataEncryptionEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + 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(), +}, + }, + AdministratorLoginPassword = "newpassword", + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + 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"), + GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), + GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithMajorVersionUpgrade + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithMajorVersionUpgrade() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithMajorVersionUpgrade.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Version = PostgreSqlFlexibleServerVersion.Ver14, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "pgtestsvc4"; + 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}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetPostgreSqlFlexibleServers_ServerList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 = "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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // 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.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerRestartWithFailover + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestartWithFailover() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestartWithFailover.json + // this example is just showing the usage of "Servers_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(); + // 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 + PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() + { + RestartWithFailover = true, + FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, + }; + await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed, postgreSqlFlexibleServerRestartParameter: postgreSqlFlexibleServerRestartParameter); + + Console.WriteLine($"Succeeded"); + } + + // ServerStart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Start_ServerStart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStart.json + // this example is just showing the usage of "Servers_Start" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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.StartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerStop + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Stop_ServerStop() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStop.json + // this example is just showing the usage of "Servers_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(); + // 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.StopAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + // CheckMigrationNameAvailability [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] 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 aa24818fdb52..3d6ac24429fa 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,5 +18,147 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + PostgreSqlPrivateEndpointConnectionResource 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 + PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Approve or reject a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // 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; + + // the variable result is 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}"); + } + + // Gets list of private endpoint connections on a server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 bf80aeab8c24..c69ce8d02e4e 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 @@ -18,5 +18,106 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateEndpointConnectionResource { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionResource result = await postgreSqlPrivateEndpointConnection.GetAsync(); + + // the variable result is 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}"); + } + + // Deletes a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + await postgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Update private endpoint connection Tags + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdatePrivateEndpointConnectionTags() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json + // this example is just showing the usage of "PrivateEndpointConnections_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 PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() + { + Tags = +{ +["key1"] = "val1", +["key2"] = "val2", +["key3"] = "val3", +}, + }; + ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); + 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 + PostgreSqlPrivateEndpointConnectionData 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_PostgreSqlPrivateLinkResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs index 93f07a725eaa..b6df7e81e6fd 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs @@ -16,5 +16,36 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateLinkResource { + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateLinkResource created on azure + // for more information of creating PostgreSqlPrivateLinkResource, please refer to the document of PostgreSqlPrivateLinkResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string groupName = "plr"; + ResourceIdentifier postgreSqlPrivateLinkResourceId = PostgreSqlPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, groupName); + PostgreSqlPrivateLinkResource postgreSqlPrivateLinkResource = client.GetPostgreSqlPrivateLinkResource(postgreSqlPrivateLinkResourceId); + + // invoke the operation + PostgreSqlPrivateLinkResource result = await postgreSqlPrivateLinkResource.GetAsync(); + + // the variable result is 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}"); + } } } 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 28a4bd65bf16..2ad5a19787e9 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 @@ -16,5 +16,107 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlPrivateLinkResourceCollection { + // Gets private link resources for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + PostgreSqlPrivateLinkResource 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 + PostgreSqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + bool result = await collection.ExistsAsync(groupName); + + Console.WriteLine($"Succeeded: {result}"); + } } } 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 6452e478356e..92fd03305708 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 @@ -18,5 +18,101 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerAdministratorResource { + // ServerAdministratorGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerAdministratorGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminGet.json + // this example is just showing the usage of "ServerAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + PostgreSqlServerAdministratorResource result = await postgreSqlServerAdministrator.GetAsync(); + + // the variable result is 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}"); + } + + // ServerAdministratorCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerAdministratorCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + 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; + + // the variable result is 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}"); + } + + // ServerAdministratorsDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerAdministratorsDelete() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } } } 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 cd9f805c856a..74fbe57fcddd 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 @@ -19,5 +19,339 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerCollection { + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"), DateTimeOffset.Parse("2017-12-14T00:00:37.467Z")), new AzureLocation("brazilsouth")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 PostgreSqlServerResource + PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForDefaultCreate("cloudsa", "") + { + SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, + MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, + StorageProfile = new PostgreSqlStorageProfile() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, + StorageInMB = 128000, + }, + }, new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a replica server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAReplicaServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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_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 = "testserver-replica1"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForReplica(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")), new AzureLocation("westcentralus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a server as a geo restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForGeoRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")), new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + PostgreSqlServerResource result = await collection.GetAsync(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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // 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(); + // 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 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // 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(); + // 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_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 and iterate over the result + string serverName = "testserver-master"; + await foreach (PostgreSqlServerResource 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 + PostgreSqlServerData 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/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs index 0dc653d88da7..7aadc6043331 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,5 +18,148 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerKeyCollection { + // List the keys for a PostgreSQL Server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheKeysForAPostgreSQLServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + PostgreSqlServerKeyResource result = await collection.GetAsync(keyName); + + // the variable result is 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}"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + bool result = await collection.ExistsAsync(keyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // 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; + + // the variable result is 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 59ff5bf09076..dab6192a125b 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 @@ -18,5 +18,102 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerKeyResource { + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + PostgreSqlServerKeyResource result = await postgreSqlServerKey.GetAsync(); + + // the variable result is 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}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + 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; + + // the variable result is 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}"); + } + + // Delete the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteThePostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } } } 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 1e5a3525028b..ed008efe8e30 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 @@ -19,5 +19,275 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerResource { + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + 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; + + // the variable result is 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; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-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 PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task UpdateConfigurations_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json + // this example is just showing the usage of "ServerParameters_ListUpdateConfigurations" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlConfigurationList value = new PostgreSqlConfigurationList(); + ArmOperation lro = await postgreSqlServer.UpdateConfigurationsAsync(WaitUntil.Completed, value); + PostgreSqlConfigurationList result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + // LogFileList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetLogFiles_LogFileList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/LogFileListByServer.json + // this example is just showing the usage of "LogFiles_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlLogFile item in postgreSqlServer.GetLogFilesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetRecoverableServer_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/RecoverableServersGet.json + // this example is just showing the usage of "RecoverableServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlRecoverableServerResourceData result = await postgreSqlServer.GetRecoverableServerAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // PerformanceTiersList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetServerBasedPerformanceTiers_PerformanceTiersList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json + // this example is just showing the usage of "ServerBasedPerformanceTier_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlPerformanceTierProperties item in postgreSqlServer.GetServerBasedPerformanceTiersAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } 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 f09451d8708e..fe2ade8a83d3 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,5 +18,200 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(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}"); + } + + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + bool result = await collection.ExistsAsync(securityAlertPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // 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; + + // the variable result is 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}"); + } + + // List the server's threat detection policies + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheServerSThreatDetectionPolicies() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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}"); + } + + 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 96c2be64fd9c..92a7931197a1 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 @@ -18,5 +18,123 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlServerSecurityAlertPolicyResource { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyResource result = await postgreSqlServerSecurityAlertPolicy.GetAsync(); + + // the variable result is 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}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + 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 postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + { + State = PostgreSqlServerSecurityAlertPolicyState.Disabled, + SendToEmailAccountAdmins = true, + }; + ArmOperation lro = await postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData 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_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs index 8c11026522d9..9a77a4760dff 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,5 +17,148 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlVirtualNetworkRuleCollection { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(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}"); + } + + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // 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; + + // the variable result is 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}"); + } + + // List virtual network rules + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListVirtualNetworkRules() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 d1d4bf362679..ae16b246c287 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 @@ -17,5 +17,102 @@ namespace Azure.ResourceManager.PostgreSql.Samples { public partial class Sample_PostgreSqlVirtualNetworkRuleResource { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + PostgreSqlVirtualNetworkRuleResource result = await postgreSqlVirtualNetworkRule.GetAsync(); + + // the variable result is 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}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + 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; + + // the variable result is 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}"); + } + + // Delete a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } } } 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 2cebfb8f37fe..4f3c1938176e 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 @@ -16,5 +16,27 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples { public partial class Sample_TenantResourceExtensions { + // GetPrivateDnsZoneSuffix + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/GetPrivateDnsZoneSuffix.json + // this example is just showing the usage of "GetPrivateDnsZoneSuffix_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this 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 result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } From 63bd71a778746596d2606157e30d0eac16970fc7 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Thu, 20 Jul 2023 19:38:20 +0800 Subject: [PATCH 4/7] regenerate latest code and sample --- .../api/Azure.ResourceManager.PostgreSql.netstandard2.0.cs | 1 + .../Custom/Models/PostgreSqlFlexibleServerVersion.cs | 3 +++ .../Generated/Models/PostgreSqlFlexibleServerVersion.cs | 1 + 3 files changed, 5 insertions(+) diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/api/Azure.ResourceManager.PostgreSql.netstandard2.0.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/api/Azure.ResourceManager.PostgreSql.netstandard2.0.cs index 1e6ad46b6003..793d6b4c3ed0 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/api/Azure.ResourceManager.PostgreSql.netstandard2.0.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/api/Azure.ResourceManager.PostgreSql.netstandard2.0.cs @@ -1682,6 +1682,7 @@ internal PostgreSqlFlexibleServerVCoreCapability() { } public static Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion Ver12 { get { throw null; } } public static Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion Ver13 { get { throw null; } } public static Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion Ver14 { get { throw null; } } + public static Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion Ver15 { get { throw null; } } public bool Equals(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs index b8ef142fa9c9..15b6cfad13f8 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Custom/Models/PostgreSqlFlexibleServerVersion.cs @@ -12,6 +12,9 @@ namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Models /// The version of a server. public readonly partial struct PostgreSqlFlexibleServerVersion : IEquatable { + /// 15. + [CodeGenMember("Fifteen")] + public static PostgreSqlFlexibleServerVersion Ver15 { get; } = new PostgreSqlFlexibleServerVersion(Ver15Value); /// 14. [CodeGenMember("Fourteen")] public static PostgreSqlFlexibleServerVersion Ver14 { get; } = new PostgreSqlFlexibleServerVersion(Ver14Value); diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs index 783be58e72b2..78241a06877a 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/src/PostgreSqlFlexibleServers/Generated/Models/PostgreSqlFlexibleServerVersion.cs @@ -22,6 +22,7 @@ public PostgreSqlFlexibleServerVersion(string value) _value = value ?? throw new ArgumentNullException(nameof(value)); } + private const string Ver15Value = "15"; private const string Ver14Value = "14"; private const string Ver13Value = "13"; private const string Ver12Value = "12"; From 12be45997cc520ac2d8cb42efd3b9af8e34c8865 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Fri, 21 Jul 2023 17:16:18 +0800 Subject: [PATCH 5/7] remove 'generated' folder --- ...ample_PostgreSqlConfigurationCollection.cs | 164 ----- .../Sample_PostgreSqlConfigurationResource.cs | 90 --- .../Sample_PostgreSqlDatabaseCollection.cs | 164 ----- .../Sample_PostgreSqlDatabaseResource.cs | 118 ---- ...Sample_PostgreSqlFirewallRuleCollection.cs | 161 ----- .../Sample_PostgreSqlFirewallRuleResource.cs | 115 ---- ...rActiveDirectoryAdministratorCollection.cs | 166 ----- ...verActiveDirectoryAdministratorResource.cs | 120 ---- ...ostgreSqlFlexibleServerBackupCollection.cs | 122 ---- ..._PostgreSqlFlexibleServerBackupResource.cs | 51 -- ...mple_PostgreSqlFlexibleServerCollection.cs | 647 ------------------ ...qlFlexibleServerConfigurationCollection.cs | 164 ----- ...eSqlFlexibleServerConfigurationResource.cs | 90 --- ...tgreSqlFlexibleServerDatabaseCollection.cs | 164 ----- ...ostgreSqlFlexibleServerDatabaseResource.cs | 118 ---- ...SqlFlexibleServerFirewallRuleCollection.cs | 161 ----- ...reSqlFlexibleServerFirewallRuleResource.cs | 115 ---- ...Sample_PostgreSqlFlexibleServerResource.cs | 645 ----------------- ...reSqlLtrServerBackupOperationCollection.cs | 122 ---- ...tgreSqlLtrServerBackupOperationResource.cs | 51 -- .../Sample_PostgreSqlMigrationCollection.cs | 222 ------ .../Sample_PostgreSqlMigrationResource.cs | 153 ----- ...eSqlPrivateEndpointConnectionCollection.cs | 164 ----- ...greSqlPrivateEndpointConnectionResource.cs | 123 ---- .../Sample_PostgreSqlPrivateLinkResource.cs | 51 -- ...PostgreSqlPrivateLinkResourceCollection.cs | 122 ---- ...e_PostgreSqlServerAdministratorResource.cs | 118 ---- .../Sample_PostgreSqlServerCollection.cs | 357 ---------- .../Sample_PostgreSqlServerKeyCollection.cs | 165 ----- .../Sample_PostgreSqlServerKeyResource.cs | 119 ---- .../Sample_PostgreSqlServerResource.cs | 293 -------- ...eSqlServerSecurityAlertPolicyCollection.cs | 217 ------ ...greSqlServerSecurityAlertPolicyResource.cs | 140 ---- ..._PostgreSqlVirtualNetworkRuleCollection.cs | 164 ----- ...le_PostgreSqlVirtualNetworkRuleResource.cs | 118 ---- .../Sample_SubscriptionResourceExtensions.cs | 139 ---- .../Sample_TenantResourceExtensions.cs | 42 -- 37 files changed, 6255 deletions(-) delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_SubscriptionResourceExtensions.cs delete mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_TenantResourceExtensions.cs 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 deleted file mode 100644 index b1452f449c1a..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlConfigurationCollection - { - // ConfigurationCreateOrUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() - { - Value = "off", - Source = "user-override", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, 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 - PostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlConfigurationResource 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 - PostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlConfigurationResource - PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ConfigurationList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 9f5d42ea4b6f..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlConfigurationResource.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlConfigurationResource - { - // ConfigurationCreateOrUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ConfigurationCreateOrUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlConfigurationResource created on azure - // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - 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; - - // the variable result is 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}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlConfigurationResource created on azure - // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); - - // invoke the operation - 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 - PostgreSqlConfigurationData 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_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs deleted file mode 100644 index 2b5b7fe205f5..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlDatabaseCollection - { - // DatabaseCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_DatabaseCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() - { - Charset = "UTF8", - Collation = "English_United States.1252", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 - PostgreSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlDatabaseResource 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 - PostgreSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlDatabaseResource - PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // DatabaseList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_DatabaseList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 295a72ca38bf..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlDatabaseResource.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlDatabaseResource - { - // DatabaseCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_DatabaseCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - 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; - - // the variable result is 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}"); - } - - // DatabaseDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DatabaseDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseDelete.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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); - - // invoke the operation - await postgreSqlDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // DatabaseGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlDatabaseResource created on azure - // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); - - // invoke the operation - 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 - PostgreSqlDatabaseData 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_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs deleted file mode 100644 index 9acad1a3bb4f..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Net; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager; -using Azure.ResourceManager.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlFirewallRuleCollection - { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_FirewallRuleCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 - PostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFirewallRuleResource 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 - PostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlFirewallRuleResource - PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_FirewallRuleList() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 0a5596a5e9a2..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Net; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager; -using Azure.ResourceManager.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlFirewallRuleResource - { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_FirewallRuleCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - 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; - - // the variable result is 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}"); - } - - // FirewallRuleDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_FirewallRuleDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/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 PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); - - // invoke the operation - await postgreSqlFirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // FirewallRuleGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure - // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); - - // invoke the operation - 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 - PostgreSqlFirewallRuleData 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_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs deleted file mode 100644 index 6c4f9cbb456e..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs +++ /dev/null @@ -1,166 +0,0 @@ -// 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.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection - { - // Adds an Active DIrectory Administrator for the server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource - PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - - // invoke the operation - string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() - { - PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, - PrincipalName = "testuser1@microsoft.com", - TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectId, 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 - PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource - PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - - // invoke the operation - string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await collection.GetAsync(objectId); - - // the variable result is 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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // 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); - - Console.WriteLine($"Succeeded: {result}"); - } - - // AdministratorsListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_AdministratorsListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 9fc3b57b010b..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs +++ /dev/null @@ -1,120 +0,0 @@ -// 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.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource - { - // Adds an Active DIrectory Administrator for the server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 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; - - // the variable result is 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}"); - } - - // AdministratorDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_AdministratorDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/AdministratorDelete.json - // this example is just showing the usage of "Administrators_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); - - // invoke the operation - await postgreSqlFlexibleServerActiveDirectoryAdministrator.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure - // 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 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(); - - // the variable result is 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}"); - } - } -} 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 deleted file mode 100644 index 6f1dc8d67033..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs +++ /dev/null @@ -1,122 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerBackupCollection - { - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerBackupResource - PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - - // invoke the operation - string backupName = "daily_20210615T160516"; - PostgreSqlFlexibleServerBackupResource result = await collection.GetAsync(backupName); - - // the variable result is 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}"); - } - - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerBackupResource - PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - - // invoke the operation - string backupName = "daily_20210615T160516"; - bool result = await collection.ExistsAsync(backupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // List backups for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListBackupsForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "postgresqltestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 63e2ef95d7a2..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerBackupResource - { - // Get a backup for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetABackupForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerBackupResource created on azure - // for more information of creating PostgreSqlFlexibleServerBackupResource, please refer to the document of PostgreSqlFlexibleServerBackupResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "postgresqltestserver"; - string backupName = "daily_20210615T160516"; - ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); - PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerBackupData 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_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs deleted file mode 100644 index 51fa2c1c2a41..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs +++ /dev/null @@ -1,647 +0,0 @@ -// 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.Models; -using Azure.ResourceManager.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerCollection - { - // Create a database as a geo-restore in geo-paired location - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateGeoRestoreWithDataEncryptionEnabled.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5geo"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus")) - { - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - 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(), -}, - }, - 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"), - GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), - GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // Create a database as a point in time restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreatePointInTimeRestore.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // Create a new server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreate.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLogin = "cloudsa", - AdministratorLoginPassword = "password", - Version = PostgreSqlFlexibleServerVersion.Ver12, - Storage = new PostgreSqlFlexibleServerStorage() - { - StorageSizeInGB = 512, - AutoGrow = StorageAutoGrow.Disabled, - Tier = PostgreSqlManagedDiskPerformanceTier.P20, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // Create a new server with active directory authentication enabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticationEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithAadAuthEnabled.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLogin = "cloudsa", - AdministratorLoginPassword = "password", - Version = PostgreSqlFlexibleServerVersion.Ver12, - Storage = new PostgreSqlFlexibleServerStorage() - { - StorageSizeInGB = 512, - AutoGrow = StorageAutoGrow.Disabled, - Tier = PostgreSqlManagedDiskPerformanceTier.P20, - }, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() - { - ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, - PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, - TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() - { - KeyType = PostgreSqlFlexibleServerKeyType.SystemManaged, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerCreateReplica - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerCreateReplica() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReplica.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5rep"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), -}, - }, - 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"), - GeoBackupKeyUri = new Uri(""), - GeoBackupUserAssignedIdentityId = "", - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.Replica, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerCreateReviveDropped - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerCreateReviveDropped() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReviveDropped.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc5-rev"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc5"), - PointInTimeUtc = DateTimeOffset.Parse("2023-04-27T00:04:59.4078005+00:00"), - CreateMode = PostgreSqlFlexibleServerCreateMode.ReviveDropped, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerCreateWithDataEncryptionEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithDataEncryptionEnabled.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/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() - { - StorageSizeInGB = 512, - AutoGrow = StorageAutoGrow.Disabled, - }, - 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"), - GeoBackupKeyUri = new Uri(""), - GeoBackupUserAssignedIdentityId = "", - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, - }, - 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() - { - Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, - }, - AvailabilityZone = "1", - CreateMode = PostgreSqlFlexibleServerCreateMode.Create, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc1"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerGetWithVnet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGetWithVnet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); - } - - // ServerGetWithVnet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGetWithVnet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PostgreSqlFlexibleServerResource - PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerListByResourceGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ServerListByResourceGroup() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // 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()) - { - // the variable item is 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"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetReplicas_ReplicasListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // 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)) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index fce6949afb5e..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection - { - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ConfigurationList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - PostgreSqlFlexibleServerConfigurationResource 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 - PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Update a user configuration - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAUserConfiguration() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerConfigurationResource - 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; - - // the variable result is 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 deleted file mode 100644 index 4f46abf4d161..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerConfigurationResource - { - // ConfigurationGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ConfigurationGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure - // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string configurationName = "array_nulls"; - ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); - - // invoke the operation - PostgreSqlFlexibleServerConfigurationResource result = await postgreSqlFlexibleServerConfiguration.GetAsync(); - - // the variable result is 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}"); - } - - // Update a user configuration - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAUserConfiguration() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure - // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string configurationName = "event_scheduler"; - ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); - PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); - - // invoke the operation - PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() - { - Value = "on", - Source = "user-override", - }; - ArmOperation lro = await postgreSqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFlexibleServerConfigurationResource result = lro.Value; - - // the variable result is 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_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs deleted file mode 100644 index 06adde43546c..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerDatabaseCollection - { - // Create a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() - { - Charset = "utf8", - Collation = "en_US.utf8", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 - PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - PostgreSqlFlexibleServerDatabaseResource 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 - PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlFlexibleServerDatabaseResource - PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // List databases in a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListDatabasesInAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 41c9b31286ab..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerDatabaseResource - { - // Create a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - 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; - - // the variable result is 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}"); - } - - // Delete a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/DatabaseDelete.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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); - - // invoke the operation - await postgreSqlFlexibleServerDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Get a database - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetADatabase() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure - // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - string databaseName = "db1"; - ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerDatabaseData 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_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs deleted file mode 100644 index de5714383984..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Net; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerFirewallRuleCollection - { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_FirewallRuleCreate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 - PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - PostgreSqlFlexibleServerFirewallRuleResource 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 - PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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); - - // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource - PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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); - - // 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()) - { - // the variable item is 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"); - } - } -} 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 deleted file mode 100644 index 3a12ebab4a88..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Net; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource - { - // FirewallRuleCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_FirewallRuleCreate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - 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; - - // the variable result is 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}"); - } - - // FirewallRuleDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_FirewallRuleDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); - - // invoke the operation - await postgreSqlFlexibleServerFirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // FirewallRuleList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_FirewallRuleList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure - // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string firewallRuleName = "rule1"; - ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); - - // invoke the operation - 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 - PostgreSqlFlexibleServerFirewallRuleData 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_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs deleted file mode 100644 index 8428494bd42e..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs +++ /dev/null @@ -1,645 +0,0 @@ -// 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.Models; -using Azure.ResourceManager.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlFlexibleServerResource - { - // ServerCapabilitiesList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetServerCapabilities_ServerCapabilitiesList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "pgtestsvc4"; - 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}"); - } - - Console.WriteLine($"Succeeded"); - } - - // ServerUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLoginPassword = "newpassword", - Storage = new PostgreSqlFlexibleServerStorage() - { - StorageSizeInGB = 1024, - AutoGrow = StorageAutoGrow.Enabled, - Tier = PostgreSqlManagedDiskPerformanceTier.P30, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithAadAuthEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithAadAuthEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithAadAuthEnabled.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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - AdministratorLoginPassword = "newpassword", - Storage = new PostgreSqlFlexibleServerStorage() - { - StorageSizeInGB = 1024, - AutoGrow = StorageAutoGrow.Disabled, - Tier = PostgreSqlManagedDiskPerformanceTier.P30, - }, - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() - { - ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, - PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, - TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithCustomerMaintenanceWindow - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.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(); - // 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 = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() - { - CustomWindow = "Enabled", - StartHour = 8, - StartMinute = 0, - DayOfWeek = 0, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithDataEncryptionEnabled - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithDataEncryptionEnabled() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithDataEncryptionEnabled.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(); - // 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 = "TestGroup"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), - Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) - { - 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(), -}, - }, - AdministratorLoginPassword = "newpassword", - Backup = new PostgreSqlFlexibleServerBackupProperties() - { - BackupRetentionDays = 20, - }, - 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"), - GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), - GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", - KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, - }, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerUpdateWithMajorVersionUpgrade - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdateWithMajorVersionUpgrade() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithMajorVersionUpgrade.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(); - // 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 = "pgtestsvc4"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() - { - Version = PostgreSqlFlexibleServerVersion.Ver14, - CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, - }; - ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlFlexibleServerResource result = lro.Value; - - // the variable result is 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}"); - } - - // ServerDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); - // 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}"); - } - - // ServerGetWithVnet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGetWithVnet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "pgtestsvc4"; - 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}"); - } - - // ServerList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetPostgreSqlFlexibleServers_ServerList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 = "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"); - } - - // ServerRestart - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestart() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestart.json - // this example is just showing the usage of "Servers_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(); - // 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.RestartAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerRestartWithFailover - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestartWithFailover() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestartWithFailover.json - // this example is just showing the usage of "Servers_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(); - // 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 - PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() - { - RestartWithFailover = true, - FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, - }; - await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed, postgreSqlFlexibleServerRestartParameter: postgreSqlFlexibleServerRestartParameter); - - Console.WriteLine($"Succeeded"); - } - - // ServerStart - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Start_ServerStart() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStart.json - // this example is just showing the usage of "Servers_Start" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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.StartAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerStop - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Stop_ServerStop() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStop.json - // this example is just showing the usage of "Servers_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(); - // 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.StopAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // CheckMigrationNameAvailability - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CheckPostgreSqlMigrationNameAvailability_CheckMigrationNameAvailability() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckMigrationNameAvailability.json - // this example is just showing the usage of "CheckMigrationNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlCheckMigrationNameAvailabilityContent content = new PostgreSqlCheckMigrationNameAvailabilityContent("name1", new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers/migrations")); - PostgreSqlCheckMigrationNameAvailabilityContent result = await postgreSqlFlexibleServer.CheckPostgreSqlMigrationNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - // List all server log files for a server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetPostgreSqlFlexibleServerLogFiles_ListAllServerLogFilesForAServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LogFilesListByServer.json - // this example is just showing the usage of "LogFiles_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(); - // 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 = "postgresqltestsvc1"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerLogFile item in postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerLogFilesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Sample_Prebackup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task TriggerLtrPreBackupFlexibleServer_SamplePrebackup() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionPreBackup.json - // this example is just showing the usage of "FlexibleServer_TriggerLtrPreBackup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerLtrPreBackupContent content = new PostgreSqlFlexibleServerLtrPreBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1")); - PostgreSqlFlexibleServerLtrPreBackupResult result = await postgreSqlFlexibleServer.TriggerLtrPreBackupFlexibleServerAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Sample_ExecuteBackup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task StartLtrBackupFlexibleServer_SampleExecuteBackup() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionBackup.json - // this example is just showing the usage of "FlexibleServer_StartLtrBackup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerLtrBackupContent content = new PostgreSqlFlexibleServerLtrBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1"), new PostgreSqlFlexibleServerBackupStoreDetails(new string[] - { -"sasuri" - })); - ArmOperation lro = await postgreSqlFlexibleServer.StartLtrBackupFlexibleServerAsync(WaitUntil.Completed, content); - PostgreSqlFlexibleServerLtrBackupResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - } -} 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 deleted file mode 100644 index a2769c985b45..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs +++ /dev/null @@ -1,122 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlLtrServerBackupOperationCollection - { - // Sample - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_Sample() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlLtrServerBackupOperationResource - PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); - - // invoke the operation - string backupName = "backup1"; - PostgreSqlLtrServerBackupOperationResource result = await collection.GetAsync(backupName); - - // the variable result is 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}"); - } - - // Sample - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_Sample() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlLtrServerBackupOperationResource - PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); - - // invoke the operation - string backupName = "backup1"; - bool result = await collection.ExistsAsync(backupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Sample List of Long Tern Retention Operations by Flexible Server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - } -} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs deleted file mode 100644 index 740f0e8d51b8..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlLtrServerBackupOperationResource - { - // Sample - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_Sample() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlLtrServerBackupOperationResource created on azure - // for more information of creating PostgreSqlLtrServerBackupOperationResource, please refer to the document of PostgreSqlLtrServerBackupOperationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rgLongTermRetention"; - string serverName = "pgsqlltrtestserver"; - string backupName = "backup1"; - ResourceIdentifier postgreSqlLtrServerBackupOperationResourceId = PostgreSqlLtrServerBackupOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); - PostgreSqlLtrServerBackupOperationResource postgreSqlLtrServerBackupOperation = client.GetPostgreSqlLtrServerBackupOperationResource(postgreSqlLtrServerBackupOperationResourceId); - - // invoke the operation - PostgreSqlLtrServerBackupOperationResource result = await postgreSqlLtrServerBackupOperation.GetAsync(); - - // the variable result is 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}"); - } - } -} 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 deleted file mode 100644 index f95efbe08309..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationCollection.cs +++ /dev/null @@ -1,222 +0,0 @@ -// 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.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlMigrationCollection - { - // Migrations Create by passing user names - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_MigrationsCreateByPassingUserNames() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create_With_Other_Users.json - // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlMigrationResource - PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - - // invoke the operation - string migrationName = "testmigration"; - PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) - { - 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")) - { - SourceServerUsername = "newadmin@testsource", - TargetServerUsername = "targetadmin", - }, - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); - PostgreSqlMigrationResource result = lro.Value; - - // the variable result is 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}"); - } - - // Migrations_Create - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_MigrationsCreate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create.json - // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlMigrationResource - PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - - // invoke the operation - string migrationName = "testmigration"; - PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) - { - 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" -}, - OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); - PostgreSqlMigrationResource result = lro.Value; - - // the variable result is 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}"); - } - - // Migrations_Get - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_MigrationsGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 - 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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlMigrationResource - PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - - // invoke the operation - string migrationName = "testmigration"; - PostgreSqlMigrationResource result = await collection.GetAsync(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}"); - } - - // Migrations_Get - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_MigrationsGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 - 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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // get the collection of this PostgreSqlMigrationResource - PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - - // invoke the operation - string migrationName = "testmigration"; - bool result = await collection.ExistsAsync(migrationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Migrations_ListByTargetServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_MigrationsListByTargetServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // 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 targetDbServerName = "testtarget"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // 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)) - { - // the variable item is 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; - // 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 deleted file mode 100644 index 9a77beeed9e7..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlMigrationResource.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_PostgreSqlMigrationResource - { - // Migrations_Get - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_MigrationsGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlMigrationResource created on azure - // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string targetDbServerName = "testtarget"; - string migrationName = "testmigration"; - ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); - PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); - - // invoke the operation - PostgreSqlMigrationResource result = await postgreSqlMigration.GetAsync(); - - // the variable result is 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}"); - } - - // Cancel migration - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CancelMigration() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlMigrationResource created on azure - // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string targetDbServerName = "testtarget"; - string migrationName = "testmigration"; - ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); - PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); - - // invoke the operation - PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() - { - Cancel = PostgreSqlMigrationCancel.True, - }; - PostgreSqlMigrationResource result = await postgreSqlMigration.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 - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Migrations_Update - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_MigrationsUpdate() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlMigrationResource created on azure - // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string targetDbServerName = "testtarget"; - string migrationName = "testmigration"; - ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); - PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); - - // invoke the operation - PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() - { - SetupLogicalReplicationOnSourceDbIfNeeded = PostgreSqlMigrationLogicalReplicationOnSourceDb.True, - }; - PostgreSqlMigrationResource result = await postgreSqlMigration.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 - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Migrations_Delete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_MigrationsDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlMigrationResource created on azure - // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string targetDbServerName = "testtarget"; - string migrationName = "testmigration"; - ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); - PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); - - // invoke the operation - await postgreSqlMigration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - } -} 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 deleted file mode 100644 index 3d6ac24429fa..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection - { - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - PostgreSqlPrivateEndpointConnectionResource 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 - PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Approve or reject a private endpoint connection with a given name. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateEndpointConnectionResource - PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - - // 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; - - // the variable result is 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}"); - } - - // Gets list of private endpoint connections on a server. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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; - // 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 deleted file mode 100644 index c69ce8d02e4e..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs +++ /dev/null @@ -1,123 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlPrivateEndpointConnectionResource - { - // Gets private endpoint connection. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - PostgreSqlPrivateEndpointConnectionResource result = await postgreSqlPrivateEndpointConnection.GetAsync(); - - // the variable result is 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}"); - } - - // Deletes a private endpoint connection with a given name. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - await postgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // Update private endpoint connection Tags - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdatePrivateEndpointConnectionTags() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json - // this example is just showing the usage of "PrivateEndpointConnections_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 PostgreSqlPrivateEndpointConnectionResource created on azure - // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string privateEndpointConnectionName = "private-endpoint-connection-name"; - ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); - - // invoke the operation - PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() - { - Tags = -{ -["key1"] = "val1", -["key2"] = "val2", -["key3"] = "val3", -}, - }; - ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); - 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 - PostgreSqlPrivateEndpointConnectionData 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_PostgreSqlPrivateLinkResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs deleted file mode 100644 index b6df7e81e6fd..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlPrivateLinkResource - { - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlPrivateLinkResource created on azure - // for more information of creating PostgreSqlPrivateLinkResource, please refer to the document of PostgreSqlPrivateLinkResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - string groupName = "plr"; - ResourceIdentifier postgreSqlPrivateLinkResourceId = PostgreSqlPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, groupName); - PostgreSqlPrivateLinkResource postgreSqlPrivateLinkResource = client.GetPostgreSqlPrivateLinkResource(postgreSqlPrivateLinkResourceId); - - // invoke the operation - PostgreSqlPrivateLinkResource result = await postgreSqlPrivateLinkResource.GetAsync(); - - // the variable result is 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}"); - } - } -} 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 deleted file mode 100644 index 2ad5a19787e9..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs +++ /dev/null @@ -1,122 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlPrivateLinkResourceCollection - { - // Gets private link resources for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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}"); - } - - Console.WriteLine($"Succeeded"); - } - - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateLinkResource - PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - - // invoke the operation - string groupName = "plr"; - PostgreSqlPrivateLinkResource 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 - PostgreSqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Gets a private link resource for PostgreSQL. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetsAPrivateLinkResourceForPostgreSQL() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - string serverName = "test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlPrivateLinkResource - PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - - // invoke the operation - string groupName = "plr"; - bool result = await collection.ExistsAsync(groupName); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} 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 deleted file mode 100644 index 92fd03305708..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerAdministratorResource - { - // ServerAdministratorGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerAdministratorGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminGet.json - // this example is just showing the usage of "ServerAdministrators_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); - - // invoke the operation - PostgreSqlServerAdministratorResource result = await postgreSqlServerAdministrator.GetAsync(); - - // the variable result is 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}"); - } - - // ServerAdministratorCreate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_ServerAdministratorCreate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - 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; - - // the variable result is 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}"); - } - - // ServerAdministratorsDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerAdministratorsDelete() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure - // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; - ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); - - // invoke the operation - await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - } -} 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 deleted file mode 100644 index 74fbe57fcddd..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerCollection.cs +++ /dev/null @@ -1,357 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerCollection - { - // Create a database as a point in time restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; - 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 = "targetserver"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"), DateTimeOffset.Parse("2017-12-14T00:00:37.467Z")), new AzureLocation("brazilsouth")) - { - Sku = new PostgreSqlSku("B_Gen5_2") - { - Tier = PostgreSqlSkuTier.Basic, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a new server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateANewServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreate.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 PostgreSqlServerResource - PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - - // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForDefaultCreate("cloudsa", "") - { - SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, - MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, - StorageProfile = new PostgreSqlStorageProfile() - { - BackupRetentionDays = 7, - GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, - StorageInMB = 128000, - }, - }, new AzureLocation("westus")) - { - Sku = new PostgreSqlSku("B_Gen5_2") - { - Tier = PostgreSqlSkuTier.Basic, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a replica server - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAReplicaServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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_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 = "testserver-replica1"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForReplica(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")), new AzureLocation("westcentralus")) - { - Sku = new PostgreSqlSku("GP_Gen5_2") - { - Tier = PostgreSqlSkuTier.GeneralPurpose, - Capacity = 2, - Family = "Gen5", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Create a server as a geo restore - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json - // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; - 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 = "targetserver"; - PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForGeoRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")), new AzureLocation("westus")) - { - Sku = new PostgreSqlSku("GP_Gen5_2") - { - Tier = PostgreSqlSkuTier.GeneralPurpose, - Capacity = 2, - Family = "Gen5", - }, - Tags = -{ -["ElasticServer"] = "1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // 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(); - // 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 = "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 - string serverName = "pgtestsvc1"; - PostgreSqlServerResource result = await collection.GetAsync(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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_ServerGet() - { - // 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(); - // 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 = "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 - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // ServerListByResourceGroup - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ServerListByResourceGroup() - { - // 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(); - // 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 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}"); - } - - Console.WriteLine($"Succeeded"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetReplicas_ReplicasListByServer() - { - // 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(); - // 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_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 and iterate over the result - string serverName = "testserver-master"; - await foreach (PostgreSqlServerResource 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 - PostgreSqlServerData 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/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs deleted file mode 100644 index 7aadc6043331..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyCollection.cs +++ /dev/null @@ -1,165 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerKeyCollection - { - // List the keys for a PostgreSQL Server. - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListTheKeysForAPostgreSQLServer() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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"); - } - - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - PostgreSqlServerKeyResource result = await collection.GetAsync(keyName); - - // the variable result is 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}"); - } - - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Creates or updates a PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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 = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerKeyResource - PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - - // 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; - - // the variable result is 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 deleted file mode 100644 index dab6192a125b..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerKeyResource.cs +++ /dev/null @@ -1,119 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerKeyResource - { - // Get the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); - - // invoke the operation - PostgreSqlServerKeyResource result = await postgreSqlServerKey.GetAsync(); - - // the variable result is 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}"); - } - - // Creates or updates a PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - 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; - - // the variable result is 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}"); - } - - // Delete the PostgreSQL Server key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteThePostgreSQLServerKey() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerKeyResource created on azure - // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - string keyName = "someVault_someKey_01234567890123456789012345678901"; - ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); - PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); - - // invoke the operation - await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - } -} 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 deleted file mode 100644 index ed008efe8e30..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerResource.cs +++ /dev/null @@ -1,293 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerResource - { - // ServerUpdate - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_ServerUpdate() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - 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; - - // the variable result is 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; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerDelete - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_ServerDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-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 PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - await postgreSqlServer.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ServerGet - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_ServerGet() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - 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 - PostgreSqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // ServerList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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"); - } - - // ServerRestart - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Restart_ServerRestart() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerRestart.json - // this example is just showing the usage of "Servers_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - await postgreSqlServer.RestartAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - - // ConfigurationList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task UpdateConfigurations_ConfigurationList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json - // this example is just showing the usage of "ServerParameters_ListUpdateConfigurations" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - PostgreSqlConfigurationList value = new PostgreSqlConfigurationList(); - ArmOperation lro = await postgreSqlServer.UpdateConfigurationsAsync(WaitUntil.Completed, value); - PostgreSqlConfigurationList result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - // LogFileList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetLogFiles_LogFileList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/LogFileListByServer.json - // this example is just showing the usage of "LogFiles_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlLogFile item in postgreSqlServer.GetLogFilesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // ReplicasListByServer - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetRecoverableServer_ReplicasListByServer() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/RecoverableServersGet.json - // this example is just showing the usage of "RecoverableServers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // 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"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation - PostgreSqlRecoverableServerResourceData result = await postgreSqlServer.GetRecoverableServerAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - - // PerformanceTiersList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetServerBasedPerformanceTiers_PerformanceTiersList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json - // this example is just showing the usage of "ServerBasedPerformanceTier_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlPerformanceTierProperties item in postgreSqlServer.GetServerBasedPerformanceTiersAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} 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 deleted file mode 100644 index fe2ade8a83d3..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs +++ /dev/null @@ -1,217 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection - { - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(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}"); - } - - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Update a server's threat detection policy with all parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - 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 - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a server's threat detection policy with minimal parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlServerSecurityAlertPolicyResource - PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - - // 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; - - // the variable result is 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}"); - } - - // List the server's threat detection policies - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListTheServerSThreatDetectionPolicies() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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}"); - } - - 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 deleted file mode 100644 index 92a7931197a1..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs +++ /dev/null @@ -1,140 +0,0 @@ -// 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.PostgreSql; -using Azure.ResourceManager.PostgreSql.Models; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlServerSecurityAlertPolicyResource - { - // Get a server's threat detection policy - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - PostgreSqlServerSecurityAlertPolicyResource result = await postgreSqlServerSecurityAlertPolicy.GetAsync(); - - // the variable result is 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}"); - } - - // Update a server's threat detection policy with all parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - 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 postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Update a server's threat detection policy with minimal parameters - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure - // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); - - // invoke the operation - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() - { - State = PostgreSqlServerSecurityAlertPolicyState.Disabled, - SendToEmailAccountAdmins = true, - }; - ArmOperation lro = await postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 - PostgreSqlServerSecurityAlertPolicyData 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_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs deleted file mode 100644 index 9a77a4760dff..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlVirtualNetworkRuleCollection - { - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(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}"); - } - - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - bool result = await collection.ExistsAsync(virtualNetworkRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Create or update a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // get the collection of this PostgreSqlVirtualNetworkRuleResource - PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - - // 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; - - // the variable result is 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}"); - } - - // List virtual network rules - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListVirtualNetworkRules() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlServerResource created on azure - // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); - - // 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()) - { - // the variable item is 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; - // 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 deleted file mode 100644 index ae16b246c287..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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.PostgreSql; - -namespace Azure.ResourceManager.PostgreSql.Samples -{ - public partial class Sample_PostgreSqlVirtualNetworkRuleResource - { - // Gets a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - 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. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); - - // invoke the operation - PostgreSqlVirtualNetworkRuleResource result = await postgreSqlVirtualNetworkRule.GetAsync(); - - // the variable result is 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}"); - } - - // Create or update a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateOrUpdateAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - 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; - - // the variable result is 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}"); - } - - // Delete a virtual network rule - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Delete_DeleteAVirtualNetworkRule() - { - // 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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure - // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "vnet-test-svr"; - string virtualNetworkRuleName = "vnet-firewall-rule"; - ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); - PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); - - // invoke the operation - await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine($"Succeeded"); - } - } -} 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 deleted file mode 100644 index 4af48973f373..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ /dev/null @@ -1,139 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; -using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_SubscriptionResourceExtensions - { - // CapabilitiesList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExecuteLocationBasedCapabilities_CapabilitiesList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CapabilitiesByLocation.json - // this example is just showing the usage of "LocationBasedCapabilities_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example 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 - AzureLocation locationName = new AzureLocation("westus"); - await foreach (PostgreSqlFlexibleServerCapabilityProperties item in subscriptionResource.ExecuteLocationBasedCapabilitiesAsync(locationName)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine($"Succeeded"); - } - - // NameAvailability - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CheckPostgreSqlFlexibleServerNameAvailability_NameAvailability() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailability.json - // this example is just showing the usage of "CheckNameAvailability_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example 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 - PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") - { - ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), - }; - PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - // NameAvailability - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_NameAvailability() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailabilityLocationBased.json - // this example is just showing the usage of "CheckNameAvailabilityWithLocation_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example 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 locationName = new AzureLocation("westus"); - PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") - { - ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), - }; - PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityWithLocationAsync(locationName, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - // VirtualNetworkSubnetUsageList - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/VirtualNetworkSubnetUsage.json - // this example is just showing the usage of "VirtualNetworkSubnetUsage_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example 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 locationName = new AzureLocation("westus"); - PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter = new PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter() - { - VirtualNetworkArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), - }; - PostgreSqlFlexibleServerVirtualNetworkSubnetUsageResult result = await subscriptionResource.ExecuteVirtualNetworkSubnetUsageAsync(locationName, postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} 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 deleted file mode 100644 index 4f3c1938176e..000000000000 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/generated/Samples/Sample_TenantResourceExtensions.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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; -using Azure.ResourceManager.PostgreSql.FlexibleServers; - -namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples -{ - public partial class Sample_TenantResourceExtensions - { - // GetPrivateDnsZoneSuffix - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/GetPrivateDnsZoneSuffix.json - // this example is just showing the usage of "GetPrivateDnsZoneSuffix_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(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this 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 result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} From ad351187735d1fd6948d15fbfcf69e00089b60bf Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Fri, 21 Jul 2023 17:20:06 +0800 Subject: [PATCH 6/7] add back Generated folder with correct case --- ...ample_PostgreSqlConfigurationCollection.cs | 164 +++++ .../Sample_PostgreSqlConfigurationResource.cs | 90 +++ .../Sample_PostgreSqlDatabaseCollection.cs | 164 +++++ .../Sample_PostgreSqlDatabaseResource.cs | 118 ++++ ...Sample_PostgreSqlFirewallRuleCollection.cs | 161 +++++ .../Sample_PostgreSqlFirewallRuleResource.cs | 115 ++++ ...rActiveDirectoryAdministratorCollection.cs | 166 +++++ ...verActiveDirectoryAdministratorResource.cs | 120 ++++ ...ostgreSqlFlexibleServerBackupCollection.cs | 122 ++++ ..._PostgreSqlFlexibleServerBackupResource.cs | 51 ++ ...mple_PostgreSqlFlexibleServerCollection.cs | 647 ++++++++++++++++++ ...qlFlexibleServerConfigurationCollection.cs | 164 +++++ ...eSqlFlexibleServerConfigurationResource.cs | 90 +++ ...tgreSqlFlexibleServerDatabaseCollection.cs | 164 +++++ ...ostgreSqlFlexibleServerDatabaseResource.cs | 118 ++++ ...SqlFlexibleServerFirewallRuleCollection.cs | 161 +++++ ...reSqlFlexibleServerFirewallRuleResource.cs | 115 ++++ ...Sample_PostgreSqlFlexibleServerResource.cs | 645 +++++++++++++++++ ...reSqlLtrServerBackupOperationCollection.cs | 122 ++++ ...tgreSqlLtrServerBackupOperationResource.cs | 51 ++ .../Sample_PostgreSqlMigrationCollection.cs | 222 ++++++ .../Sample_PostgreSqlMigrationResource.cs | 153 +++++ ...eSqlPrivateEndpointConnectionCollection.cs | 164 +++++ ...greSqlPrivateEndpointConnectionResource.cs | 123 ++++ .../Sample_PostgreSqlPrivateLinkResource.cs | 51 ++ ...PostgreSqlPrivateLinkResourceCollection.cs | 122 ++++ ...e_PostgreSqlServerAdministratorResource.cs | 118 ++++ .../Sample_PostgreSqlServerCollection.cs | 357 ++++++++++ .../Sample_PostgreSqlServerKeyCollection.cs | 165 +++++ .../Sample_PostgreSqlServerKeyResource.cs | 119 ++++ .../Sample_PostgreSqlServerResource.cs | 293 ++++++++ ...eSqlServerSecurityAlertPolicyCollection.cs | 217 ++++++ ...greSqlServerSecurityAlertPolicyResource.cs | 140 ++++ ..._PostgreSqlVirtualNetworkRuleCollection.cs | 164 +++++ ...le_PostgreSqlVirtualNetworkRuleResource.cs | 118 ++++ .../Sample_SubscriptionResourceExtensions.cs | 139 ++++ .../Sample_TenantResourceExtensions.cs | 42 ++ 37 files changed, 6255 insertions(+) create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs 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 new file mode 100644 index 000000000000..b1452f449c1a --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlConfigurationCollection + { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() + { + Value = "off", + Source = "user-override", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlConfigurationResource 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 + PostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlConfigurationResource + PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..9f5d42ea4b6f --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs @@ -0,0 +1,90 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlConfigurationResource + { + // ConfigurationCreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ConfigurationCreateOrUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + 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; + + // the variable result is 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}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlConfigurationResource created on azure + // for more information of creating PostgreSqlConfigurationResource, please refer to the document of PostgreSqlConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlConfigurationResourceId = PostgreSqlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); + + // invoke the operation + 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 + PostgreSqlConfigurationData 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_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs new file mode 100644 index 000000000000..2b5b7fe205f5 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlDatabaseCollection + { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() + { + Charset = "UTF8", + Collation = "English_United States.1252", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlDatabaseResource 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 + PostgreSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlDatabaseResource + PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // DatabaseList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_DatabaseList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..295a72ca38bf --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlDatabaseResource + { + // DatabaseCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_DatabaseCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // DatabaseDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DatabaseDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + await postgreSqlDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // DatabaseGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlDatabaseResource created on azure + // for more information of creating PostgreSqlDatabaseResource, please refer to the document of PostgreSqlDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlDatabaseResourceId = PostgreSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlDatabaseData 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_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs new file mode 100644 index 000000000000..9acad1a3bb4f --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlFirewallRuleCollection + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFirewallRuleResource 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 + PostgreSqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlFirewallRuleResource + PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..0a5596a5e9a2 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlFirewallRuleResource + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/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 PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFirewallRuleResource created on azure + // for more information of creating PostgreSqlFirewallRuleResource, please refer to the document of PostgreSqlFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFirewallRuleResourceId = PostgreSqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFirewallRuleData 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_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs new file mode 100644 index 000000000000..6c4f9cbb456e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs @@ -0,0 +1,166 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection + { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() + { + PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, + PrincipalName = "testuser1@microsoft.com", + TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectId, 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 + PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); + + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await collection.GetAsync(objectId); + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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); + + Console.WriteLine($"Succeeded: {result}"); + } + + // AdministratorsListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_AdministratorsListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..9fc3b57b010b --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs @@ -0,0 +1,120 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource + { + // Adds an Active DIrectory Administrator for the server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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; + + // the variable result is 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}"); + } + + // AdministratorDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_AdministratorDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/AdministratorDelete.json + // this example is just showing the usage of "Administrators_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); + + // invoke the operation + await postgreSqlFlexibleServerActiveDirectoryAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource created on azure + // 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 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(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..6f1dc8d67033 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerBackupCollection + { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + PostgreSqlFlexibleServerBackupResource result = await collection.GetAsync(backupName); + + // the variable result is 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}"); + } + + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerBackupResource + PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); + + // invoke the operation + string backupName = "daily_20210615T160516"; + bool result = await collection.ExistsAsync(backupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List backups for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListBackupsForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "postgresqltestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..63e2ef95d7a2 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerBackupResource + { + // Get a backup for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetABackupForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerBackupResource created on azure + // for more information of creating PostgreSqlFlexibleServerBackupResource, please refer to the document of PostgreSqlFlexibleServerBackupResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "postgresqltestserver"; + string backupName = "daily_20210615T160516"; + ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); + PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerBackupData 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_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs new file mode 100644 index 000000000000..51fa2c1c2a41 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs @@ -0,0 +1,647 @@ +// 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.Models; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerCollection + { + // Create a database as a geo-restore in geo-paired location + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateGeoRestoreWithDataEncryptionEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5geo"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("eastus")) + { + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + 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(), +}, + }, + 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"), + GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), + GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.GeoRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.PointInTimeRestore, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P20, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // Create a new server with active directory authentication enabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticationEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithAadAuthEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLogin = "cloudsa", + AdministratorLoginPassword = "password", + Version = PostgreSqlFlexibleServerVersion.Ver12, + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P20, + }, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + { + KeyType = PostgreSqlFlexibleServerKeyType.SystemManaged, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateReplica + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateReplica() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReplica.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5rep"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +}, + }, + 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"), + GeoBackupKeyUri = new Uri(""), + GeoBackupUserAssignedIdentityId = "", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), + PointInTimeUtc = DateTimeOffset.Parse("2021-06-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.Replica, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateReviveDropped + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateReviveDropped() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateReviveDropped.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc5-rev"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + SourceServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgtestsvc5"), + PointInTimeUtc = DateTimeOffset.Parse("2023-04-27T00:04:59.4078005+00:00"), + CreateMode = PostgreSqlFlexibleServerCreateMode.ReviveDropped, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerCreateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerCreateWithDataEncryptionEnabled.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerData data = new PostgreSqlFlexibleServerData(new AzureLocation("westus")) + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D4s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/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() + { + StorageSizeInGB = 512, + AutoGrow = StorageAutoGrow.Disabled, + }, + 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"), + GeoBackupKeyUri = new Uri(""), + GeoBackupUserAssignedIdentityId = "", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, + }, + 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() + { + Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, + }, + AvailabilityZone = "1", + CreateMode = PostgreSqlFlexibleServerCreateMode.Create, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PostgreSqlFlexibleServerResource + PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // 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)) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..fce6949afb5e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection + { + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + PostgreSqlFlexibleServerConfigurationResource 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 + PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); + + // invoke the operation + string configurationName = "array_nulls"; + bool result = await collection.ExistsAsync(configurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerConfigurationResource + 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; + + // the variable result is 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 new file mode 100644 index 000000000000..4f46abf4d161 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs @@ -0,0 +1,90 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerConfigurationResource + { + // ConfigurationGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ConfigurationGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "array_nulls"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationResource result = await postgreSqlFlexibleServerConfiguration.GetAsync(); + + // the variable result is 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}"); + } + + // Update a user configuration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAUserConfiguration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerConfigurationResource created on azure + // for more information of creating PostgreSqlFlexibleServerConfigurationResource, please refer to the document of PostgreSqlFlexibleServerConfigurationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string configurationName = "event_scheduler"; + ResourceIdentifier postgreSqlFlexibleServerConfigurationResourceId = PostgreSqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); + PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); + + // invoke the operation + PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() + { + Value = "on", + Source = "user-override", + }; + ArmOperation lro = await postgreSqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServerConfigurationResource result = lro.Value; + + // the variable result is 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_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs new file mode 100644 index 000000000000..06adde43546c --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerDatabaseCollection + { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() + { + Charset = "utf8", + Collation = "en_US.utf8", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + PostgreSqlFlexibleServerDatabaseResource 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 + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlFlexibleServerDatabaseResource + PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); + + // invoke the operation + string databaseName = "db1"; + bool result = await collection.ExistsAsync(databaseName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List databases in a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListDatabasesInAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..41c9b31286ab --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerDatabaseResource + { + // Create a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + 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; + + // the variable result is 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}"); + } + + // Delete a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/DatabaseDelete.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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + await postgreSqlFlexibleServerDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Get a database + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetADatabase() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerDatabaseResource created on azure + // for more information of creating PostgreSqlFlexibleServerDatabaseResource, please refer to the document of PostgreSqlFlexibleServerDatabaseResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + string databaseName = "db1"; + ResourceIdentifier postgreSqlFlexibleServerDatabaseResourceId = PostgreSqlFlexibleServerDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerDatabaseData 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_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs new file mode 100644 index 000000000000..de5714383984 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerFirewallRuleCollection + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + PostgreSqlFlexibleServerFirewallRuleResource 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 + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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); + + // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource + PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); + + // invoke the operation + string firewallRuleName = "rule1"; + bool result = await collection.ExistsAsync(firewallRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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); + + // 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()) + { + // the variable item is 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"); + } + } +} 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 new file mode 100644 index 000000000000..3a12ebab4a88 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Net; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource + { + // FirewallRuleCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_FirewallRuleCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + 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; + + // the variable result is 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}"); + } + + // FirewallRuleDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_FirewallRuleDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + await postgreSqlFlexibleServerFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // FirewallRuleList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_FirewallRuleList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerFirewallRuleResource created on azure + // for more information of creating PostgreSqlFlexibleServerFirewallRuleResource, please refer to the document of PostgreSqlFlexibleServerFirewallRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string firewallRuleName = "rule1"; + ResourceIdentifier postgreSqlFlexibleServerFirewallRuleResourceId = PostgreSqlFlexibleServerFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); + + // invoke the operation + 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 + PostgreSqlFlexibleServerFirewallRuleData 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_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs new file mode 100644 index 000000000000..8428494bd42e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs @@ -0,0 +1,645 @@ +// 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.Models; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlFlexibleServerResource + { + // ServerCapabilitiesList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetServerCapabilities_ServerCapabilitiesList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "pgtestsvc4"; + 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 1024, + AutoGrow = StorageAutoGrow.Enabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P30, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithAadAuthEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithAadAuthEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithAadAuthEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + AdministratorLoginPassword = "newpassword", + Storage = new PostgreSqlFlexibleServerStorage() + { + StorageSizeInGB = 1024, + AutoGrow = StorageAutoGrow.Disabled, + Tier = PostgreSqlManagedDiskPerformanceTier.P30, + }, + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + { + ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, + PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, + TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithCustomerMaintenanceWindow + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() + { + CustomWindow = "Enabled", + StartHour = 8, + StartMinute = 0, + DayOfWeek = 0, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithDataEncryptionEnabled + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithDataEncryptionEnabled() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithDataEncryptionEnabled.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(); + // 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 = "TestGroup"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), + Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) + { + 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(), +}, + }, + AdministratorLoginPassword = "newpassword", + Backup = new PostgreSqlFlexibleServerBackupProperties() + { + BackupRetentionDays = 20, + }, + 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"), + GeoBackupKeyUri = new Uri("https://test-geo-kv.vault.azure.net/keys/test-key1/66f57315bab34b0189daa113fbc78787"), + GeoBackupUserAssignedIdentityId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity", + KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, + }, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerUpdateWithMajorVersionUpgrade + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdateWithMajorVersionUpgrade() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerUpdateWithMajorVersionUpgrade.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(); + // 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 = "pgtestsvc4"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + { + Version = PostgreSqlFlexibleServerVersion.Ver14, + CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, + }; + ArmOperation lro = await postgreSqlFlexibleServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlFlexibleServerResource result = lro.Value; + + // the variable result is 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}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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(); + // 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}"); + } + + // ServerGetWithVnet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "pgtestsvc4"; + 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}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetPostgreSqlFlexibleServers_ServerList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-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 = "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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // 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.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerRestartWithFailover + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestartWithFailover() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerRestartWithFailover.json + // this example is just showing the usage of "Servers_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(); + // 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 + PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() + { + RestartWithFailover = true, + FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, + }; + await postgreSqlFlexibleServer.RestartAsync(WaitUntil.Completed, postgreSqlFlexibleServerRestartParameter: postgreSqlFlexibleServerRestartParameter); + + Console.WriteLine($"Succeeded"); + } + + // ServerStart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Start_ServerStart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStart.json + // this example is just showing the usage of "Servers_Start" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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.StartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerStop + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Stop_ServerStop() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/ServerStop.json + // this example is just showing the usage of "Servers_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(); + // 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.StopAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // CheckMigrationNameAvailability + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckPostgreSqlMigrationNameAvailability_CheckMigrationNameAvailability() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckMigrationNameAvailability.json + // this example is just showing the usage of "CheckMigrationNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlCheckMigrationNameAvailabilityContent content = new PostgreSqlCheckMigrationNameAvailabilityContent("name1", new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers/migrations")); + PostgreSqlCheckMigrationNameAvailabilityContent result = await postgreSqlFlexibleServer.CheckPostgreSqlMigrationNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // List all server log files for a server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetPostgreSqlFlexibleServerLogFiles_ListAllServerLogFilesForAServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LogFilesListByServer.json + // this example is just showing the usage of "LogFiles_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(); + // 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 = "postgresqltestsvc1"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerLogFile item in postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerLogFilesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Sample_Prebackup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task TriggerLtrPreBackupFlexibleServer_SamplePrebackup() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionPreBackup.json + // this example is just showing the usage of "FlexibleServer_TriggerLtrPreBackup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerLtrPreBackupContent content = new PostgreSqlFlexibleServerLtrPreBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1")); + PostgreSqlFlexibleServerLtrPreBackupResult result = await postgreSqlFlexibleServer.TriggerLtrPreBackupFlexibleServerAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Sample_ExecuteBackup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task StartLtrBackupFlexibleServer_SampleExecuteBackup() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/LongTermRetentionBackup.json + // this example is just showing the usage of "FlexibleServer_StartLtrBackup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerLtrBackupContent content = new PostgreSqlFlexibleServerLtrBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1"), new PostgreSqlFlexibleServerBackupStoreDetails(new string[] + { +"sasuri" + })); + ArmOperation lro = await postgreSqlFlexibleServer.StartLtrBackupFlexibleServerAsync(WaitUntil.Completed, content); + PostgreSqlFlexibleServerLtrBackupResult result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} 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 new file mode 100644 index 000000000000..a2769c985b45 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlLtrServerBackupOperationCollection + { + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlLtrServerBackupOperationResource + PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); + + // invoke the operation + string backupName = "backup1"; + PostgreSqlLtrServerBackupOperationResource result = await collection.GetAsync(backupName); + + // the variable result is 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}"); + } + + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlLtrServerBackupOperationResource + PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); + + // invoke the operation + string backupName = "backup1"; + bool result = await collection.ExistsAsync(backupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Sample List of Long Tern Retention Operations by Flexible Server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + } +} diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.cs new file mode 100644 index 000000000000..740f0e8d51b8 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationResource.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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlLtrServerBackupOperationResource + { + // Sample + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_Sample() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlLtrServerBackupOperationResource created on azure + // for more information of creating PostgreSqlLtrServerBackupOperationResource, please refer to the document of PostgreSqlLtrServerBackupOperationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "rgLongTermRetention"; + string serverName = "pgsqlltrtestserver"; + string backupName = "backup1"; + ResourceIdentifier postgreSqlLtrServerBackupOperationResourceId = PostgreSqlLtrServerBackupOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); + PostgreSqlLtrServerBackupOperationResource postgreSqlLtrServerBackupOperation = client.GetPostgreSqlLtrServerBackupOperationResource(postgreSqlLtrServerBackupOperationResourceId); + + // invoke the operation + PostgreSqlLtrServerBackupOperationResource result = await postgreSqlLtrServerBackupOperation.GetAsync(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..f95efbe08309 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs @@ -0,0 +1,222 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlMigrationCollection + { + // Migrations Create by passing user names + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_MigrationsCreateByPassingUserNames() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create_With_Other_Users.json + // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) + { + 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")) + { + SourceServerUsername = "newadmin@testsource", + TargetServerUsername = "targetadmin", + }, + DbsToMigrate = +{ +"db1","db2","db3","db4" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); + PostgreSqlMigrationResource result = lro.Value; + + // the variable result is 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}"); + } + + // Migrations_Create + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_MigrationsCreate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/Migrations_Create.json + // this example is just showing the usage of "Migrations_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationData data = new PostgreSqlMigrationData(new AzureLocation("westus")) + { + 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" +}, + OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); + PostgreSqlMigrationResource result = lro.Value; + + // the variable result is 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}"); + } + + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + PostgreSqlMigrationResource result = await collection.GetAsync(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}"); + } + + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // get the collection of this PostgreSqlMigrationResource + PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); + + // invoke the operation + string migrationName = "testmigration"; + bool result = await collection.ExistsAsync(migrationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Migrations_ListByTargetServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_MigrationsListByTargetServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // 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 targetDbServerName = "testtarget"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // 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)) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..9a77beeed9e7 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs @@ -0,0 +1,153 @@ +// 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.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_PostgreSqlMigrationResource + { + // Migrations_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_MigrationsGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationResource result = await postgreSqlMigration.GetAsync(); + + // the variable result is 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}"); + } + + // Cancel migration + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CancelMigration() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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 + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() + { + Cancel = PostgreSqlMigrationCancel.True, + }; + PostgreSqlMigrationResource result = await postgreSqlMigration.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 + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Migrations_Update + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_MigrationsUpdate() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() + { + SetupLogicalReplicationOnSourceDbIfNeeded = PostgreSqlMigrationLogicalReplicationOnSourceDb.True, + }; + PostgreSqlMigrationResource result = await postgreSqlMigration.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 + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Migrations_Delete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_MigrationsDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlMigrationResource created on azure + // for more information of creating PostgreSqlMigrationResource, please refer to the document of PostgreSqlMigrationResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string targetDbServerName = "testtarget"; + string migrationName = "testmigration"; + ResourceIdentifier postgreSqlMigrationResourceId = PostgreSqlMigrationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, targetDbServerName, migrationName); + PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); + + // invoke the operation + await postgreSqlMigration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..3d6ac24429fa --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection + { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + PostgreSqlPrivateEndpointConnectionResource 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 + PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Approve or reject a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateEndpointConnectionResource + PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); + + // 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; + + // the variable result is 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}"); + } + + // Gets list of private endpoint connections on a server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..c69ce8d02e4e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs @@ -0,0 +1,123 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateEndpointConnectionResource + { + // Gets private endpoint connection. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionResource result = await postgreSqlPrivateEndpointConnection.GetAsync(); + + // the variable result is 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}"); + } + + // Deletes a private endpoint connection with a given name. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + await postgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // Update private endpoint connection Tags + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdatePrivateEndpointConnectionTags() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdateTags.json + // this example is just showing the usage of "PrivateEndpointConnections_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 PostgreSqlPrivateEndpointConnectionResource created on azure + // for more information of creating PostgreSqlPrivateEndpointConnectionResource, please refer to the document of PostgreSqlPrivateEndpointConnectionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string privateEndpointConnectionName = "private-endpoint-connection-name"; + ResourceIdentifier postgreSqlPrivateEndpointConnectionResourceId = PostgreSqlPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); + + // invoke the operation + PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() + { + Tags = +{ +["key1"] = "val1", +["key2"] = "val2", +["key3"] = "val3", +}, + }; + ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); + 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 + PostgreSqlPrivateEndpointConnectionData 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_PostgreSqlPrivateLinkResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResource.cs new file mode 100644 index 000000000000..b6df7e81e6fd --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResource.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; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateLinkResource + { + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlPrivateLinkResource created on azure + // for more information of creating PostgreSqlPrivateLinkResource, please refer to the document of PostgreSqlPrivateLinkResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + string groupName = "plr"; + ResourceIdentifier postgreSqlPrivateLinkResourceId = PostgreSqlPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, groupName); + PostgreSqlPrivateLinkResource postgreSqlPrivateLinkResource = client.GetPostgreSqlPrivateLinkResource(postgreSqlPrivateLinkResourceId); + + // invoke the operation + PostgreSqlPrivateLinkResource result = await postgreSqlPrivateLinkResource.GetAsync(); + + // the variable result is 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}"); + } + } +} 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 new file mode 100644 index 000000000000..2ad5a19787e9 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs @@ -0,0 +1,122 @@ +// 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; +using Azure.ResourceManager.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlPrivateLinkResourceCollection + { + // Gets private link resources for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + PostgreSqlPrivateLinkResource 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 + PostgreSqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Gets a private link resource for PostgreSQL. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetsAPrivateLinkResourceForPostgreSQL() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + string serverName = "test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlPrivateLinkResource + PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); + + // invoke the operation + string groupName = "plr"; + bool result = await collection.ExistsAsync(groupName); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} 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 new file mode 100644 index 000000000000..92fd03305708 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerAdministratorResource + { + // ServerAdministratorGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerAdministratorGet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminGet.json + // this example is just showing the usage of "ServerAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + PostgreSqlServerAdministratorResource result = await postgreSqlServerAdministrator.GetAsync(); + + // the variable result is 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}"); + } + + // ServerAdministratorCreate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServerAdministratorCreate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + 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; + + // the variable result is 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}"); + } + + // ServerAdministratorsDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerAdministratorsDelete() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerAdministratorResource created on azure + // for more information of creating PostgreSqlServerAdministratorResource, please refer to the document of PostgreSqlServerAdministratorResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc4"; + ResourceIdentifier postgreSqlServerAdministratorResourceId = PostgreSqlServerAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); + + // invoke the operation + await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..74fbe57fcddd --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs @@ -0,0 +1,357 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerCollection + { + // Create a database as a point in time restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreatePointInTimeRestore.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"), DateTimeOffset.Parse("2017-12-14T00:00:37.467Z")), new AzureLocation("brazilsouth")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a new server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateANewServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreate.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 PostgreSqlServerResource + PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); + + // invoke the operation + string serverName = "pgtestsvc4"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForDefaultCreate("cloudsa", "") + { + SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, + MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, + StorageProfile = new PostgreSqlStorageProfile() + { + BackupRetentionDays = 7, + GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, + StorageInMB = 128000, + }, + }, new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("B_Gen5_2") + { + Tier = PostgreSqlSkuTier.Basic, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a replica server + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAReplicaServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateReplicaMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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_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 = "testserver-replica1"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForReplica(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")), new AzureLocation("westcentralus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Create a server as a geo restore + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerCreateGeoRestoreMode.json + // this example is just showing the usage of "Servers_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/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 = "TargetResourceGroup"; + 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 = "targetserver"; + PostgreSqlServerCreateOrUpdateContent content = new PostgreSqlServerCreateOrUpdateContent(new PostgreSqlServerPropertiesForGeoRestore(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")), new AzureLocation("westus")) + { + Sku = new PostgreSqlSku("GP_Gen5_2") + { + Tier = PostgreSqlSkuTier.GeneralPurpose, + Capacity = 2, + Family = "Gen5", + }, + Tags = +{ +["ElasticServer"] = "1", +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + PostgreSqlServerResource result = await collection.GetAsync(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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServerGet() + { + // 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(); + // 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 = "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 + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ServerListByResourceGroup + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServerListByResourceGroup() + { + // 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(); + // 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 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}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetReplicas_ReplicasListByServer() + { + // 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(); + // 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_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 and iterate over the result + string serverName = "testserver-master"; + await foreach (PostgreSqlServerResource 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 + PostgreSqlServerData 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/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs new file mode 100644 index 000000000000..7aadc6043331 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs @@ -0,0 +1,165 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerKeyCollection + { + // List the keys for a PostgreSQL Server. + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheKeysForAPostgreSQLServer() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + PostgreSqlServerKeyResource result = await collection.GetAsync(keyName); + + // the variable result is 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}"); + } + + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + bool result = await collection.ExistsAsync(keyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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 = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerKeyResource + PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); + + // 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; + + // the variable result is 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 new file mode 100644 index 000000000000..dab6192a125b --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs @@ -0,0 +1,119 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerKeyResource + { + // Get the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + PostgreSqlServerKeyResource result = await postgreSqlServerKey.GetAsync(); + + // the variable result is 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}"); + } + + // Creates or updates a PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + 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; + + // the variable result is 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}"); + } + + // Delete the PostgreSQL Server key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteThePostgreSQLServerKey() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerKeyResource created on azure + // for more information of creating PostgreSqlServerKeyResource, please refer to the document of PostgreSqlServerKeyResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ResourceIdentifier postgreSqlServerKeyResourceId = PostgreSqlServerKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, keyName); + PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); + + // invoke the operation + await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..ed008efe8e30 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs @@ -0,0 +1,293 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerResource + { + // ServerUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServerUpdate() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + 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; + + // the variable result is 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; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerDelete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-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 PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ServerGet + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServerGet() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + 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 + PostgreSqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ServerList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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"); + } + + // ServerRestart + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Restart_ServerRestart() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerRestart.json + // this example is just showing the usage of "Servers_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + await postgreSqlServer.RestartAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // ConfigurationList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task UpdateConfigurations_ConfigurationList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationsUpdateByServer.json + // this example is just showing the usage of "ServerParameters_ListUpdateConfigurations" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlConfigurationList value = new PostgreSqlConfigurationList(); + ArmOperation lro = await postgreSqlServer.UpdateConfigurationsAsync(WaitUntil.Completed, value); + PostgreSqlConfigurationList result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + // LogFileList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetLogFiles_LogFileList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/LogFileListByServer.json + // this example is just showing the usage of "LogFiles_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlLogFile item in postgreSqlServer.GetLogFilesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ReplicasListByServer + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetRecoverableServer_ReplicasListByServer() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/RecoverableServersGet.json + // this example is just showing the usage of "RecoverableServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // 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"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation + PostgreSqlRecoverableServerResourceData result = await postgreSqlServer.GetRecoverableServerAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + // PerformanceTiersList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetServerBasedPerformanceTiers_PerformanceTiersList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json + // this example is just showing the usage of "ServerBasedPerformanceTier_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlPerformanceTierProperties item in postgreSqlServer.GetServerBasedPerformanceTiersAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..fe2ade8a83d3 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs @@ -0,0 +1,217 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection + { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(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}"); + } + + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + bool result = await collection.ExistsAsync(securityAlertPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlServerSecurityAlertPolicyResource + PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); + + // 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; + + // the variable result is 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}"); + } + + // List the server's threat detection policies + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListTheServerSThreatDetectionPolicies() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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}"); + } + + 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 new file mode 100644 index 000000000000..92a7931197a1 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs @@ -0,0 +1,140 @@ +// 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.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlServerSecurityAlertPolicyResource + { + // Get a server's threat detection policy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyResource result = await postgreSqlServerSecurityAlertPolicy.GetAsync(); + + // the variable result is 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}"); + } + + // Update a server's threat detection policy with all parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + 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 postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Update a server's threat detection policy with minimal parameters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerSecurityAlertPolicyResource created on azure + // for more information of creating PostgreSqlServerSecurityAlertPolicyResource, please refer to the document of PostgreSqlServerSecurityAlertPolicyResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + ResourceIdentifier postgreSqlServerSecurityAlertPolicyResourceId = PostgreSqlServerSecurityAlertPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); + + // invoke the operation + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + { + State = PostgreSqlServerSecurityAlertPolicyState.Disabled, + SendToEmailAccountAdmins = true, + }; + ArmOperation lro = await postgreSqlServerSecurityAlertPolicy.UpdateAsync(WaitUntil.Completed, 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 + PostgreSqlServerSecurityAlertPolicyData 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_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs new file mode 100644 index 000000000000..9a77a4760dff --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs @@ -0,0 +1,164 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlVirtualNetworkRuleCollection + { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(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}"); + } + + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // get the collection of this PostgreSqlVirtualNetworkRuleResource + PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); + + // 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; + + // the variable result is 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}"); + } + + // List virtual network rules + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListVirtualNetworkRules() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlServerResource created on azure + // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); + + // 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()) + { + // the variable item is 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; + // 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 new file mode 100644 index 000000000000..ae16b246c287 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs @@ -0,0 +1,118 @@ +// 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.PostgreSql; + +namespace Azure.ResourceManager.PostgreSql.Samples +{ + public partial class Sample_PostgreSqlVirtualNetworkRuleResource + { + // Gets a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + 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. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + PostgreSqlVirtualNetworkRuleResource result = await postgreSqlVirtualNetworkRule.GetAsync(); + + // the variable result is 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}"); + } + + // Create or update a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateOrUpdateAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + 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; + + // the variable result is 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}"); + } + + // Delete a virtual network rule + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteAVirtualNetworkRule() + { + // 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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlVirtualNetworkRuleResource created on azure + // for more information of creating PostgreSqlVirtualNetworkRuleResource, please refer to the document of PostgreSqlVirtualNetworkRuleResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + string serverName = "vnet-test-svr"; + string virtualNetworkRuleName = "vnet-firewall-rule"; + ResourceIdentifier postgreSqlVirtualNetworkRuleResourceId = PostgreSqlVirtualNetworkRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); + + // invoke the operation + await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} 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 new file mode 100644 index 000000000000..4af48973f373 --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/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; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + // CapabilitiesList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteLocationBasedCapabilities_CapabilitiesList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CapabilitiesByLocation.json + // this example is just showing the usage of "LocationBasedCapabilities_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 + AzureLocation locationName = new AzureLocation("westus"); + await foreach (PostgreSqlFlexibleServerCapabilityProperties item in subscriptionResource.ExecuteLocationBasedCapabilitiesAsync(locationName)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // NameAvailability + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckPostgreSqlFlexibleServerNameAvailability_NameAvailability() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailability.json + // this example is just showing the usage of "CheckNameAvailability_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 + PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") + { + ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), + }; + PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // NameAvailability + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_NameAvailability() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/CheckNameAvailabilityLocationBased.json + // this example is just showing the usage of "CheckNameAvailabilityWithLocation_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 locationName = new AzureLocation("westus"); + PostgreSqlFlexibleServerNameAvailabilityContent content = new PostgreSqlFlexibleServerNameAvailabilityContent("name1") + { + ResourceType = new ResourceType("Microsoft.DBforPostgreSQL/flexibleServers"), + }; + PostgreSqlFlexibleServerNameAvailabilityResult result = await subscriptionResource.CheckPostgreSqlFlexibleServerNameAvailabilityWithLocationAsync(locationName, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + // VirtualNetworkSubnetUsageList + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/VirtualNetworkSubnetUsage.json + // this example is just showing the usage of "VirtualNetworkSubnetUsage_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example 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 locationName = new AzureLocation("westus"); + PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter = new PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter() + { + VirtualNetworkArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), + }; + PostgreSqlFlexibleServerVirtualNetworkSubnetUsageResult result = await subscriptionResource.ExecuteVirtualNetworkSubnetUsageAsync(locationName, postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} 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 new file mode 100644 index 000000000000..4f3c1938176e --- /dev/null +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/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.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.PostgreSql.FlexibleServers; + +namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples +{ + public partial class Sample_TenantResourceExtensions + { + // GetPrivateDnsZoneSuffix + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-03-01-preview/examples/GetPrivateDnsZoneSuffix.json + // this example is just showing the usage of "GetPrivateDnsZoneSuffix_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(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this 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 result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} From aaf657bca6173b5e3e780364134f7a831b7ae1a5 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Fri, 21 Jul 2023 17:42:24 +0800 Subject: [PATCH 7/7] revert unnecessary change in mysql --- .../src/MySql/Custom/Models/MySqlServerVersion.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs index 79e3fb6a1563..21890a5b4575 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerVersion.cs @@ -1,9 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// + #nullable disable using System; +using System.ComponentModel; using Azure.Core; namespace Azure.ResourceManager.MySql.Models