From 0f5b4bea5c1ac0c4a37f00c0361dbe5b99ed9261 Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Fri, 24 Mar 2023 20:53:20 +0530 Subject: [PATCH 1/5] Fix private_endpoint_connections hydrate call --- azure/table_azure_cosmosdb_account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/table_azure_cosmosdb_account.go b/azure/table_azure_cosmosdb_account.go index aa18c53f..e8e9877b 100644 --- a/azure/table_azure_cosmosdb_account.go +++ b/azure/table_azure_cosmosdb_account.go @@ -336,7 +336,7 @@ func cosmosDBPrivateEndpointConnectionMap(ctx context.Context, d *transform.Tran info := d.HydrateItem.(databaseAccountInfo) conns := info.DatabaseAccount.PrivateEndpointConnections - if len(*conns) == 0 { + if conns == nil || len(*conns) == 0 { return nil, nil } From f86e9d77f8d1c6ef0ca08e2f977b9deacc5475e7 Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Mon, 27 Mar 2023 16:39:21 +0530 Subject: [PATCH 2/5] Add column restore_parameters to table azure_cosmosdb_account #593 --- azure/table_azure_cosmosdb_account.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure/table_azure_cosmosdb_account.go b/azure/table_azure_cosmosdb_account.go index e8e9877b..1821fbcf 100644 --- a/azure/table_azure_cosmosdb_account.go +++ b/azure/table_azure_cosmosdb_account.go @@ -214,6 +214,12 @@ func tableAzureCosmosDBAccount(_ context.Context) *plugin.Table { Type: proto.ColumnType_JSON, Transform: transform.FromField("DatabaseAccount.DatabaseAccountGetProperties.ReadLocations"), }, + { + Name: "restore_parameters", + Description: "Parameters to indicate the information about the restore.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("DatabaseAccount.DatabaseAccountGetProperties.RestoreParameters"), + }, { Name: "virtual_network_rules", Description: "A list of Virtual Network ACL rules configured for the Cosmos DB account.", From bf44516162cfc83e6c66c5345380d3b3f4abcb18 Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Mon, 27 Mar 2023 17:06:36 +0530 Subject: [PATCH 3/5] Update docs --- docs/tables/azure_cosmosdb_account.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/tables/azure_cosmosdb_account.md b/docs/tables/azure_cosmosdb_account.md index 00f79b53..9ffdde12 100644 --- a/docs/tables/azure_cosmosdb_account.md +++ b/docs/tables/azure_cosmosdb_account.md @@ -100,3 +100,18 @@ from azure_cosmosdb_account, jsonb_array_elements(private_endpoint_connections) as c; ``` + +### Get details of accounts restored from backup + +```sql +select + name, + restore_parameters -> 'restoreMode' as restore_mode, + restore_parameters -> 'restoreSource' as restore_source, + d ->> 'databaseName' as restored_database_name, + c as restored_collection_name +from + azure_cosmosdb_account, + jsonb_array_elements(restore_parameters -> 'databasesToRestore') d, + jsonb_array_elements_text(d -> 'collectionNames') c +``` \ No newline at end of file From 3942dab4544cde84b1fe244505be4b16748a6f6c Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Mon, 27 Mar 2023 19:22:44 +0530 Subject: [PATCH 4/5] update docs --- docs/tables/azure_cosmosdb_account.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tables/azure_cosmosdb_account.md b/docs/tables/azure_cosmosdb_account.md index 9ffdde12..7676cd43 100644 --- a/docs/tables/azure_cosmosdb_account.md +++ b/docs/tables/azure_cosmosdb_account.md @@ -106,8 +106,8 @@ from ```sql select name, - restore_parameters -> 'restoreMode' as restore_mode, - restore_parameters -> 'restoreSource' as restore_source, + restore_parameters ->> 'restoreMode' as restore_mode, + restore_parameters ->> 'restoreSource' as restore_source, d ->> 'databaseName' as restored_database_name, c as restored_collection_name from From 5b239c85898ee89111af8a07c52c5d7cbc572fe0 Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Wed, 29 Mar 2023 11:34:15 +0530 Subject: [PATCH 5/5] Update docs/tables/azure_cosmosdb_account.md Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com> --- docs/tables/azure_cosmosdb_account.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tables/azure_cosmosdb_account.md b/docs/tables/azure_cosmosdb_account.md index 7676cd43..221dd1c7 100644 --- a/docs/tables/azure_cosmosdb_account.md +++ b/docs/tables/azure_cosmosdb_account.md @@ -113,5 +113,5 @@ select from azure_cosmosdb_account, jsonb_array_elements(restore_parameters -> 'databasesToRestore') d, - jsonb_array_elements_text(d -> 'collectionNames') c + jsonb_array_elements_text(d -> 'collectionNames') c; ``` \ No newline at end of file