Skip to content

Commit 0b83034

Browse files
authored
[azure][feat] Add PostgreSQL collection for cosmos-db resources (#2170)
1 parent 3b3c4cf commit 0b83034

8 files changed

Lines changed: 939 additions & 10 deletions

File tree

plugins/azure/fix_plugin_azure/resource/cosmosdb.py

Lines changed: 536 additions & 8 deletions
Large diffs are not rendered by default.

plugins/azure/test/collector_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def test_collect(
4949
config, Cloud(id="azure"), azure_subscription, credentials, core_feedback
5050
)
5151
subscription_collector.collect()
52-
assert len(subscription_collector.graph.nodes) == 492
53-
assert len(subscription_collector.graph.edges) == 754
52+
assert len(subscription_collector.graph.nodes) == 505
53+
assert len(subscription_collector.graph.edges) == 779
5454

5555
graph_collector = MicrosoftGraphOrganizationCollector(
5656
config, Cloud(id="azure"), MicrosoftGraphOrganization(id="test", name="test"), credentials, core_feedback

plugins/azure/test/cosmos-db_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
AzureCosmosDBRestorableAccount,
77
AzureCosmosDBLocation,
88
AzureCosmosDBMongoDBCluster,
9+
AzureCosmosDBPostgresqlCluster,
910
)
1011

1112

@@ -32,3 +33,8 @@ def test_cosmos_db_location(builder: GraphBuilder) -> None:
3233
def test_mongo_db_cluster(builder: GraphBuilder) -> None:
3334
collected = roundtrip_check(AzureCosmosDBMongoDBCluster, builder)
3435
assert len(collected) == 1
36+
37+
38+
def test_postgres_cluster(builder: GraphBuilder) -> None:
39+
collected = roundtrip_check(AzureCosmosDBPostgresqlCluster, builder)
40+
assert len(collected) == 1
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"value": [
3+
{
4+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/configurations/array_nulls",
5+
"name": "array_nulls",
6+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/configurations",
7+
"systemData": {
8+
"createdBy": "user1",
9+
"createdByType": "User",
10+
"createdAt": "2020-01-01T17:18:19.1234567Z",
11+
"lastModifiedBy": "user2",
12+
"lastModifiedByType": "User",
13+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
14+
},
15+
"properties": {
16+
"description": "Enable input of NULL elements in arrays.",
17+
"dataType": "Boolean",
18+
"allowedValues": "on,off",
19+
"serverRoleGroupConfigurations": [
20+
{
21+
"role": "Coordinator",
22+
"value": "on",
23+
"defaultValue": "on",
24+
"source": "system-default"
25+
},
26+
{
27+
"role": "Worker",
28+
"value": "off",
29+
"defaultValue": "on",
30+
"source": "user-override"
31+
}
32+
],
33+
"provisioningState": "Succeeded"
34+
}
35+
},
36+
{
37+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/configurations/backslash_quote",
38+
"name": "backslash_quote",
39+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/configurations",
40+
"systemData": {
41+
"createdBy": "user1",
42+
"createdByType": "User",
43+
"createdAt": "2020-01-01T17:18:19.1234567Z",
44+
"lastModifiedBy": "user2",
45+
"lastModifiedByType": "User",
46+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
47+
},
48+
"properties": {
49+
"description": "Sets whether \"\\'\" is allowed in string literals.",
50+
"dataType": "Enumeration",
51+
"allowedValues": "safe_encoding,on,off",
52+
"serverRoleGroupConfigurations": [
53+
{
54+
"role": "Coordinator",
55+
"value": "off",
56+
"defaultValue": "safe_encoding",
57+
"source": "user-override"
58+
},
59+
{
60+
"role": "Worker",
61+
"value": "safe_encoding",
62+
"defaultValue": "safe_encoding",
63+
"source": "system-default"
64+
}
65+
],
66+
"provisioningState": "Succeeded"
67+
}
68+
},
69+
{
70+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/configurations/work_mem",
71+
"name": "work_mem",
72+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/configurations",
73+
"systemData": {
74+
"createdBy": "user1",
75+
"createdByType": "User",
76+
"createdAt": "2020-01-01T17:18:19.1234567Z",
77+
"lastModifiedBy": "user2",
78+
"lastModifiedByType": "User",
79+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
80+
},
81+
"properties": {
82+
"description": "Sets the amount of memory to be used by internal sort operations and hash tables before writing to temporary disk files.",
83+
"dataType": "Integer",
84+
"allowedValues": "4096-2097151",
85+
"serverRoleGroupConfigurations": [
86+
{
87+
"role": "Coordinator",
88+
"value": "158720",
89+
"defaultValue": "158720",
90+
"source": "system-default"
91+
},
92+
{
93+
"role": "Worker",
94+
"value": "115712",
95+
"defaultValue": "115712",
96+
"source": "system-default"
97+
}
98+
],
99+
"provisioningState": "Succeeded"
100+
}
101+
},
102+
{
103+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/configurations/client_encoding",
104+
"name": "client_encoding",
105+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/configurations",
106+
"systemData": {
107+
"createdBy": "user1",
108+
"createdByType": "User",
109+
"createdAt": "2020-01-01T17:18:19.1234567Z",
110+
"lastModifiedBy": "user2",
111+
"lastModifiedByType": "User",
112+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
113+
},
114+
"properties": {
115+
"description": "Sets the client's character set encoding.",
116+
"dataType": "Enumeration",
117+
"allowedValues": "BIG5,EUC_CN,EUC_JP,EUC_JIS_2004,EUC_KR,EUC_TW,GB18030,GBK,ISO_8859_5,ISO_8859_6,ISO_8859_7,ISO_8859_8,JOHAB,KOI8R,KOI8U,LATIN1,LATIN2,LATIN3,LATIN4,LATIN5,LATIN6,LATIN7,LATIN8,LATIN9,LATIN10,MULE_INTERNAL,SJIS,SHIFT_JIS_2004,SQL_ASCII,UHC,UTF8,WIN866,WIN874,WIN1250,WIN1251,WIN1252,WIN1253,WIN1254,WIN1255,WIN1256,WIN1257,WIN1258",
118+
"serverRoleGroupConfigurations": [
119+
{
120+
"role": "Coordinator",
121+
"value": "ISO_8859_7",
122+
"defaultValue": "sql_ascii",
123+
"source": "user-override"
124+
},
125+
{
126+
"role": "Worker",
127+
"value": "ISO_8859_7",
128+
"defaultValue": "sql_ascii",
129+
"source": "user-override"
130+
}
131+
],
132+
"provisioningState": "Succeeded"
133+
}
134+
}
135+
]
136+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"value": [
3+
{
4+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/privateEndpointConnections/private-endpoint-connection-name",
5+
"name": "private-endpoint-connection-name",
6+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/privateEndpointConnections",
7+
"systemData": {
8+
"createdBy": "user1",
9+
"createdByType": "User",
10+
"createdAt": "2022-01-01T17:18:19.1234567Z",
11+
"lastModifiedBy": "user2",
12+
"lastModifiedByType": "User",
13+
"lastModifiedAt": "2022-01-02T17:18:19.1234567Z"
14+
},
15+
"properties": {
16+
"provisioningState": "Succeeded",
17+
"privateEndpoint": {
18+
"id": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name"
19+
},
20+
"groupIds": [
21+
"coordinator"
22+
],
23+
"privateLinkServiceConnectionState": {
24+
"status": "Approved",
25+
"description": "Auto-approved",
26+
"actionsRequired": "None"
27+
}
28+
}
29+
},
30+
{
31+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster/privateEndpointConnections/private-endpoint-connection-name-2",
32+
"name": "private-endpoint-connection-name-2",
33+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/privateEndpointConnections",
34+
"systemData": {
35+
"createdBy": "user1",
36+
"createdByType": "User",
37+
"createdAt": "2022-01-01T17:18:19.1234567Z",
38+
"lastModifiedBy": "user2",
39+
"lastModifiedByType": "User",
40+
"lastModifiedAt": "2022-01-02T17:18:19.1234567Z"
41+
},
42+
"properties": {
43+
"provisioningState": "Succeeded",
44+
"privateEndpoint": {
45+
"id": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-Network/providers/Microsoft.Network/privateEndpoints/private-endpoint-name-2"
46+
},
47+
"groupIds": [
48+
"worker-0"
49+
],
50+
"privateLinkServiceConnectionState": {
51+
"status": "Approved",
52+
"description": "Auto-approved",
53+
"actionsRequired": "None"
54+
}
55+
}
56+
}
57+
]
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"value": [
3+
{
4+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/pgtestsvc4/roles/role1",
5+
"name": "role1",
6+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/roles",
7+
"systemData": {
8+
"createdBy": "user1",
9+
"createdByType": "User",
10+
"createdAt": "2020-01-01T17:18:19.1234567Z",
11+
"lastModifiedBy": "user2",
12+
"lastModifiedByType": "User",
13+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
14+
},
15+
"properties": {
16+
"provisioningState": "Succeeded"
17+
}
18+
},
19+
{
20+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/pgtestsvc4/roles/role2",
21+
"name": "role2",
22+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2/roles",
23+
"systemData": {
24+
"createdBy": "user1",
25+
"createdByType": "User",
26+
"createdAt": "2020-01-01T17:18:19.1234567Z",
27+
"lastModifiedBy": "user2",
28+
"lastModifiedByType": "User",
29+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
30+
},
31+
"properties": {
32+
"provisioningState": "Succeeded"
33+
}
34+
}
35+
]
36+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"nextLink": null,
3+
"value": [
4+
{
5+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/testcluster1",
6+
"name": "testcluster1",
7+
"type": "Microsoft.DBforPostgreSQL/serverGroupsv2",
8+
"tags": {
9+
"additionalProp1": "string"
10+
},
11+
"location": "eastus",
12+
"systemData": {
13+
"createdBy": "user1",
14+
"createdByType": "User",
15+
"createdAt": "2020-01-01T17:18:19.1234567Z",
16+
"lastModifiedBy": "user2",
17+
"lastModifiedByType": "User",
18+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
19+
},
20+
"properties": {
21+
"provisioningState": "Succeeded",
22+
"state": "Ready",
23+
"postgresqlVersion": "14",
24+
"citusVersion": "11.1",
25+
"maintenanceWindow": {
26+
"dayOfWeek": 0,
27+
"startHour": 0,
28+
"startMinute": 0,
29+
"customWindow": "Disabled"
30+
},
31+
"aadAuthEnabled": "disabled",
32+
"administratorLogin": "citus",
33+
"dataEncryption": {
34+
"type": "SystemManaged"
35+
},
36+
"passwordEnabled": "enabled",
37+
"preferredPrimaryZone": "1",
38+
"enableHa": false,
39+
"enableShardsOnCoordinator": false,
40+
"coordinatorServerEdition": "GeneralPurpose",
41+
"coordinatorStorageQuotaInMb": 2097152,
42+
"coordinatorVCores": 4,
43+
"coordinatorEnablePublicIpAccess": true,
44+
"databaseName": "citus",
45+
"nodeServerEdition": "MemoryOptimized",
46+
"nodeCount": 2,
47+
"nodeStorageQuotaInMb": 2097152,
48+
"nodeVCores": 8,
49+
"nodeEnablePublicIpAccess": false,
50+
"serverNames": [
51+
{
52+
"name": "testcluster1-c",
53+
"fullyQualifiedDomainName": "testcluster1-c.postgres.database.azure.com"
54+
},
55+
{
56+
"name": "testcluster1-w0",
57+
"fullyQualifiedDomainName": "testcluster1-w0.postgres.database.azure.com"
58+
},
59+
{
60+
"name": "testcluster1-w1",
61+
"fullyQualifiedDomainName": "testcluster1-w1.postgres.database.azure.com"
62+
}
63+
],
64+
"sourceResourceId": null,
65+
"readReplicas": [
66+
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSQL/serverGroupsv2/testreadreplica-01",
67+
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSQL/serverGroupsv2/testreadreplica-02"
68+
],
69+
"earliestRestoreTime": "2020-09-14T00:00:37.467Z",
70+
"privateEndpointConnections": []
71+
}
72+
}
73+
]
74+
}

0 commit comments

Comments
 (0)