From 6485e1aa2410083024cbefc30e441921c0fae6d6 Mon Sep 17 00:00:00 2001 From: Karan Popat Date: Wed, 29 Mar 2023 22:05:18 +0530 Subject: [PATCH] Add column `restore_parameters` to table `azure_cosmosdb_account`. Closes #593 (#594) Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com> --- azure/table_azure_cosmosdb_account.go | 6 ++++++ docs/tables/azure_cosmosdb_account.md | 15 +++++++++++++++ 2 files changed, 21 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.", diff --git a/docs/tables/azure_cosmosdb_account.md b/docs/tables/azure_cosmosdb_account.md index 00f79b53..221dd1c7 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