-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseExample.cs
112 lines (99 loc) · 4.37 KB
/
DatabaseExample.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using OCISDK.Core;
using OCISDK.Core.Common;
using OCISDK.Core.Database;
using OCISDK.Core.Database.Request;
using OCISDK.Core.Identity;
using OCISDK.Core.Identity.Request;
using System;
using System.Collections.Generic;
using System.Text;
namespace Example
{
class DatabaseExample
{
public static void DatabaseConsoleDisplay(ClientConfig config)
{
var identityClient = new IdentityClient(config)
{
Region = Regions.US_ASHBURN_1
};
var databaseClient = new DatabaseClient(config);
var listCompartmentRequest = new ListCompartmentRequest() {
CompartmentId = config.TenancyId,
CompartmentIdInSubtree = true,
AccessLevel = ListCompartmentRequest.AccessLevels.ACCESSIBLE
};
var compartments = identityClient.ListCompartment(listCompartmentRequest).Items;
Console.WriteLine("* Database------------------------");
foreach (var com in compartments)
{
if (com.LifecycleState != "ACTIVE") {
continue;
}
var listDbHomesRequest = new ListDbHomesRequest() {
CompartmentId = com.Id,
};
var dbHomes = databaseClient.ListDbHomes(listDbHomesRequest).Items;
foreach (var home in dbHomes)
{
Console.WriteLine($" DatabaseHome: {home.DisplayName}");
var listDatabasesRequest = new ListDatabasesRequest()
{
CompartmentId = com.Id,
DbHomeId = home.Id
};
var databases = databaseClient.ListDatabases(listDatabasesRequest).Items;
foreach (var database in databases)
{
Console.WriteLine($"\t|- name: {database.DbName}");
Console.WriteLine($"\t| state: {database.LifecycleState}");
Console.WriteLine($"\t| lifecycle: {database.LifecycleDetails}");
Console.WriteLine($"\t| time: {database.TimeCreated}");
}
}
}
Console.WriteLine("* DatabaseShapes------------------------");
foreach (var com in compartments)
{
if (com.LifecycleState != "ACTIVE")
{
continue;
}
var listDbSystemShapesRequest = new ListDbSystemShapesRequest()
{
CompartmentId = com.Id
};
var dbShapes = databaseClient.ListDbSystemShapes(listDbSystemShapesRequest).Items;
foreach (var shape in dbShapes)
{
Console.WriteLine($"\t|- name: {shape.Name}");
Console.WriteLine($"\t| shape: {shape.Shape}");
Console.WriteLine($"\t| shapeFamily: {shape.ShapeFamily}");
Console.WriteLine($"\t| availableCoreCount: {shape.AvailableCoreCount}");
Console.WriteLine($"\t| coreCountIncrement: {shape.CoreCountIncrement}");
Console.WriteLine($"\t| maximumNodeCount: {shape.MaximumNodeCount}");
Console.WriteLine($"\t| minimumCoreCount: {shape.MinimumCoreCount}");
Console.WriteLine($"\t| minimumNodeCount: {shape.MinimumNodeCount}");
}
}
Console.WriteLine("* DatabaseVersions------------------------");
foreach (var com in compartments)
{
if (com.LifecycleState != "ACTIVE")
{
continue;
}
var listDbVersionsRequest = new ListDbVersionsRequest() {
CompartmentId = com.Id
};
var dbVersions = databaseClient.ListDbVersions(listDbVersionsRequest).Items;
foreach (var version in dbVersions)
{
Console.WriteLine($"\t|- version: {version.Version}");
Console.WriteLine($"\t| supportsPdb: {version.SupportsPdb}");
Console.WriteLine($"\t| isLatestForMajorVersion: {version.IsLatestForMajorVersion}");
}
}
}
}
}