@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
102 lines • 3.94 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Constants } from "../common/index.js";
import { ConsistencyLevel } from "./ConsistencyLevel.js";
/**
* Represents a DatabaseAccount in the Azure Cosmos DB database service.
*/
export class DatabaseAccount {
/** The list of writable locations for a geo-replicated database account. */
writableLocations = [];
/** The list of readable locations for a geo-replicated database account. */
readableLocations = [];
/**
* The self-link for Databases in the databaseAccount.
* @deprecated Use `databasesLink`
*/
get DatabasesLink() {
return this.databasesLink;
}
/** The self-link for Databases in the databaseAccount. */
databasesLink;
/**
* The self-link for Media in the databaseAccount.
* @deprecated Use `mediaLink`
*/
get MediaLink() {
return this.mediaLink;
}
/** The self-link for Media in the databaseAccount. */
mediaLink;
/**
* Attachment content (media) storage quota in MBs ( Retrieved from gateway ).
* @deprecated use `maxMediaStorageUsageInMB`
*/
get MaxMediaStorageUsageInMB() {
return this.maxMediaStorageUsageInMB;
}
/** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */
maxMediaStorageUsageInMB;
/**
* Current attachment content (media) usage in MBs (Retrieved from gateway )
*
* Value is returned from cached information updated periodically and is not guaranteed
* to be real time.
*
* @deprecated use `currentMediaStorageUsageInMB`
*/
get CurrentMediaStorageUsageInMB() {
return this.currentMediaStorageUsageInMB;
}
/**
* Current attachment content (media) usage in MBs (Retrieved from gateway )
*
* Value is returned from cached information updated periodically and is not guaranteed
* to be real time.
*/
currentMediaStorageUsageInMB;
/**
* Gets the UserConsistencyPolicy settings.
* @deprecated use `consistencyPolicy`
*/
get ConsistencyPolicy() {
return this.consistencyPolicy;
}
/** Gets the UserConsistencyPolicy settings. */
consistencyPolicy;
enableMultipleWritableLocations;
/**
* Indicates whether per-partition failover behavior is enabled for the database account.
*/
enablePerPartitionFailover = false;
// TODO: body - any
constructor(body, headers) {
this.databasesLink = "/dbs/";
this.mediaLink = "/media/";
this.maxMediaStorageUsageInMB = headers[Constants.HttpHeaders.MaxMediaStorageUsageInMB];
this.currentMediaStorageUsageInMB = headers[Constants.HttpHeaders.CurrentMediaStorageUsageInMB];
this.consistencyPolicy = body.userConsistencyPolicy
? body.userConsistencyPolicy.defaultConsistencyLevel
: ConsistencyLevel.Session;
if (body[Constants.WritableLocations] && body.id !== "localhost") {
this.writableLocations = body[Constants.WritableLocations];
}
if (body[Constants.ReadableLocations] && body.id !== "localhost") {
this.readableLocations = body[Constants.ReadableLocations];
}
if (body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) {
this.enableMultipleWritableLocations =
body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true ||
body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === "true";
}
else {
this.enableMultipleWritableLocations = false;
}
if (body[Constants.EnablePerPartitionFailover]) {
this.enablePerPartitionFailover =
body[Constants.EnablePerPartitionFailover] === true ||
body[Constants.EnablePerPartitionFailover] === "true";
}
}
}
//# sourceMappingURL=DatabaseAccount.js.map