-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
PostgreSqlFlexibleServerDatabase.cs
62 lines (56 loc) · 2.81 KB
/
PostgreSqlFlexibleServerDatabase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using Azure.ResourceManager.PostgreSql.FlexibleServers;
using Azure.ResourceManager.PostgreSql.FlexibleServers.Models;
namespace Azure.Provisioning.PostgreSql
{
/// <summary>
/// Represents a PostGreSql flexible database.
/// </summary>
public class PostgreSqlFlexibleServerDatabase : Resource<PostgreSqlFlexibleServerDatabaseData>
{
private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/databases";
private static PostgreSqlFlexibleServerDatabaseData Empty(string name)
=> ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData();
/// <summary>
/// Creates a new instance of the <see cref="PostgreSqlFlexibleServer"/> class.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="parent">The parent.</param>
/// <param name="name">The name.</param>
/// <param name="version">The version.</param>
public PostgreSqlFlexibleServerDatabase(
IConstruct scope,
PostgreSqlFlexibleServer? parent = null,
string name = "db",
string version = PostgreSqlFlexibleServer.DefaultVersion)
: this(scope, parent, name, version, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(name: name))
{
}
private PostgreSqlFlexibleServerDatabase(
IConstruct scope,
PostgreSqlFlexibleServer? parent,
string name,
string version = PostgreSqlFlexibleServer.DefaultVersion,
bool isExisting = false,
Func<string, PostgreSqlFlexibleServerDatabaseData>? creator = null)
: base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting)
{
}
/// <summary>
/// Creates a new instance of the <see cref="PostgreSqlFlexibleServer"/> class referencing an existing instance.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="name">The resource name.</param>
/// <param name="parent">The resource group.</param>
/// <returns>The KeyVault instance.</returns>
public static PostgreSqlFlexibleServerDatabase FromExisting(IConstruct scope, string name, PostgreSqlFlexibleServer? parent)
=> new PostgreSqlFlexibleServerDatabase(scope, parent: parent, name: name, isExisting: true);
/// <inheritdoc/>
protected override Resource? FindParentInScope(IConstruct scope)
{
return scope.GetSingleResource<PostgreSqlFlexibleServer>() ?? throw new InvalidOperationException("A PostgreSQL server was not found in the construct.");
}
}
}