显示在特定数据库下的所有 Azure Cosmos DB MongoDB 集合上完成的所有突变的事件源。 这有助于在意外删除容器的情况下。 此 API 需要“Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read”权限
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections?api-version=2024-11-15
具有可选参数:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections?api-version=2024-11-15&restorableMongodbDatabaseRid={restorableMongodbDatabaseRid}&startTime={startTime}&endTime={endTime}
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
instanceId
|
path |
True
|
string
|
可还原数据库帐户的 instanceId GUID。
|
location
|
path |
True
|
string
|
Cosmos DB 区域,单词和每个单词的大小写之间的空格。
|
subscriptionId
|
path |
True
|
string
|
目标订阅的 ID。
|
api-version
|
query |
True
|
string
|
用于此操作的 API 版本。
|
endTime
|
query |
|
string
|
可还原的 MongoDB 集合事件源结束时间。
|
restorableMongodbDatabaseRid
|
query |
|
string
|
MongoDB 数据库的资源 ID。
|
startTime
|
query |
|
string
|
可还原的 MongoDB 集合事件源开始时间。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 Flow
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
CosmosDBRestorableMongodbCollectionList
示例请求
GET https://management.azure.com/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/98a570f2-63db-4117-91f0-366327b7b353/restorableMongodbCollections?api-version=2024-11-15&restorableMongodbDatabaseRid=PD5DALigDgw=
/**
* Samples for RestorableMongodbCollections List.
*/
public final class Main {
/*
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-11-15/examples/
* CosmosDBRestorableMongodbCollectionList.json
*/
/**
* Sample code: CosmosDBRestorableMongodbCollectionList.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void cosmosDBRestorableMongodbCollectionList(com.azure.resourcemanager.AzureResourceManager azure) {
azure.cosmosDBAccounts().manager().serviceClient().getRestorableMongodbCollections().list("WestUS",
"98a570f2-63db-4117-91f0-366327b7b353", "PD5DALigDgw=", null, null, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.cosmosdb import CosmosDBManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-cosmosdb
# USAGE
python cosmos_db_restorable_mongodb_collection_list.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CosmosDBManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.restorable_mongodb_collections.list(
location="WestUS",
instance_id="98a570f2-63db-4117-91f0-366327b7b353",
)
for item in response:
print(item)
# x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-11-15/examples/CosmosDBRestorableMongodbCollectionList.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcosmos_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ded6306d00ae294c24211e5069c1f56b15ba8ef5/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-11-15/examples/CosmosDBRestorableMongodbCollectionList.json
func ExampleRestorableMongodbCollectionsClient_NewListPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcosmos.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewRestorableMongodbCollectionsClient().NewListPager("WestUS", "98a570f2-63db-4117-91f0-366327b7b353", &armcosmos.RestorableMongodbCollectionsClientListOptions{RestorableMongodbDatabaseRid: to.Ptr("PD5DALigDgw="),
StartTime: nil,
EndTime: nil,
})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.RestorableMongodbCollectionsListResult = armcosmos.RestorableMongodbCollectionsListResult{
// Value: []*armcosmos.RestorableMongodbCollectionGetResult{
// {
// Name: to.Ptr("79609a98-3394-41f8-911f-cfab0c075c86"),
// Type: to.Ptr("Microsoft.DocumentDB/locations/restorableDatabaseAccounts/restorableMongodbCollections"),
// ID: to.Ptr("/subscriptions/subid/providers/Microsoft.DocumentDb/locations/westus/restorableDatabaseAccounts/98a570f2-63db-4117-91f0-366327b7b353/restorableMongodbCollections/79609a98-3394-41f8-911f-cfab0c075c86"),
// Properties: &armcosmos.RestorableMongodbCollectionProperties{
// Resource: &armcosmos.RestorableMongodbCollectionPropertiesResource{
// Rid: to.Ptr("zAyAPQAAAA=="),
// CanUndelete: to.Ptr("invalid"),
// EventTimestamp: to.Ptr("2020-10-13T04:56:42Z"),
// OperationType: to.Ptr(armcosmos.OperationTypeCreate),
// OwnerID: to.Ptr("Collection1"),
// OwnerResourceID: to.Ptr("V18LoLrv-qA="),
// },
// },
// },
// {
// Name: to.Ptr("79609a98-3394-41f8-911f-cfab0c075c86"),
// Type: to.Ptr("Microsoft.DocumentDB/locations/restorableDatabaseAccounts/restorableMongodbCollections"),
// ID: to.Ptr("/subscriptions/subid/providers/Microsoft.DocumentDb/locations/westus/restorableDatabaseAccounts/98a570f2-63db-4117-91f0-366327b7b353/restorableMongodbCollections/79609a98-3394-41f8-911f-cfab0c075c86"),
// Properties: &armcosmos.RestorableMongodbCollectionProperties{
// Resource: &armcosmos.RestorableMongodbCollectionPropertiesResource{
// Rid: to.Ptr("zAyAPQAAAA=="),
// CanUndelete: to.Ptr("notRestorable"),
// CanUndeleteReason: to.Ptr("Individual shared database collections restore is not supported. Please restore shared database to restore its collections that share the throughput."),
// EventTimestamp: to.Ptr("2020-10-13T04:56:42Z"),
// OperationType: to.Ptr(armcosmos.OperationTypeDelete),
// OwnerID: to.Ptr("Collection1"),
// OwnerResourceID: to.Ptr("V18LoLrv-qA="),
// },
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission
*
* @summary Show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-11-15/examples/CosmosDBRestorableMongodbCollectionList.json
*/
async function cosmosDbRestorableMongodbCollectionList() {
const subscriptionId = process.env["COSMOSDB_SUBSCRIPTION_ID"] || "subid";
const location = "WestUS";
const instanceId = "98a570f2-63db-4117-91f0-366327b7b353";
const restorableMongodbDatabaseRid = "PD5DALigDgw=";
const options = {
restorableMongodbDatabaseRid,
};
const credential = new DefaultAzureCredential();
const client = new CosmosDBManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.restorableMongodbCollections.list(location, instanceId, options)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"value": [
{
"id": "/subscriptions/subid/providers/Microsoft.DocumentDb/locations/westus/restorableDatabaseAccounts/98a570f2-63db-4117-91f0-366327b7b353/restorableMongodbCollections/79609a98-3394-41f8-911f-cfab0c075c86",
"type": "Microsoft.DocumentDB/locations/restorableDatabaseAccounts/restorableMongodbCollections",
"name": "79609a98-3394-41f8-911f-cfab0c075c86",
"properties": {
"resource": {
"_rid": "zAyAPQAAAA==",
"eventTimestamp": "2020-10-13T04:56:42Z",
"ownerId": "Collection1",
"ownerResourceId": "V18LoLrv-qA=",
"operationType": "Create",
"canUndelete": "invalid"
}
}
},
{
"id": "/subscriptions/subid/providers/Microsoft.DocumentDb/locations/westus/restorableDatabaseAccounts/98a570f2-63db-4117-91f0-366327b7b353/restorableMongodbCollections/79609a98-3394-41f8-911f-cfab0c075c86",
"type": "Microsoft.DocumentDB/locations/restorableDatabaseAccounts/restorableMongodbCollections",
"name": "79609a98-3394-41f8-911f-cfab0c075c86",
"properties": {
"resource": {
"_rid": "zAyAPQAAAA==",
"eventTimestamp": "2020-10-13T04:56:42Z",
"ownerId": "Collection1",
"ownerResourceId": "V18LoLrv-qA=",
"operationType": "Delete",
"canUndelete": "notRestorable",
"canUndeleteReason": "Individual shared database collections restore is not supported. Please restore shared database to restore its collections that share the throughput."
}
}
}
]
}
定义
CloudError
服务的错误响应。
ErrorResponse
错误响应。
名称 |
类型 |
说明 |
code
|
string
|
错误代码。
|
message
|
string
|
指示操作失败的原因的错误消息。
|
OperationType
枚举以指示事件的操作类型。
名称 |
类型 |
说明 |
Create
|
string
|
|
Delete
|
string
|
|
Recreate
|
string
|
|
Replace
|
string
|
|
SystemOperation
|
string
|
|
Resource
Azure Cosmos DB MongoDB 收集事件的资源
名称 |
类型 |
说明 |
_rid
|
string
|
系统生成的属性。 唯一标识符。
|
canUndelete
|
string
|
此集合的状态,用于标识此容器是否在同一帐户中可还原。
|
canUndeleteReason
|
string
|
无法在同一帐户中还原此集合的原因。
|
eventTimestamp
|
string
|
发生此收集事件的时间。
|
operationType
|
OperationType
|
此集合事件的操作类型。
|
ownerId
|
string
|
此 MongoDB 集合的名称。
|
ownerResourceId
|
string
|
此 MongoDB 集合的资源 ID。
|
RestorableMongodbCollectionGetResult
Azure Cosmos DB MongoDB 收集事件
名称 |
类型 |
说明 |
id
|
string
|
ARM 资源的唯一资源标识符。
|
name
|
string
|
ARM 资源的名称。
|
properties.resource
|
Resource
|
Azure Cosmos DB MongoDB 收集事件的资源
|
type
|
string
|
Azure 资源的类型。
|
RestorableMongodbCollectionsListResult
包含 MongoDB 集合事件及其属性的列表操作响应。