Refactor Global state into Context Files (#128)
This commit is contained in:
parent
d45af21996
commit
0011007d5f
|
@ -1,5 +1,5 @@
|
|||
import { AutopilotTier } from "../Contracts/DataModels";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { HashMap } from "./HashMap";
|
||||
|
||||
export class AuthorizationEndpoints {
|
||||
|
@ -10,7 +10,7 @@ export class AuthorizationEndpoints {
|
|||
export class BackendEndpoints {
|
||||
public static localhost: string = "https://localhost:12900";
|
||||
public static dev: string = "https://ext.documents-dev.windows-int.net";
|
||||
public static productionPortal: string = config.BACKEND_ENDPOINT || "https://main.documentdb.ext.azure.com";
|
||||
public static productionPortal: string = configContext.BACKEND_ENDPOINT || "https://main.documentdb.ext.azure.com";
|
||||
}
|
||||
|
||||
export class EndpointsRegex {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { CosmosClient, tokenProvider, endpoint, requestPlugin, getTokenFromAuthService } from "./CosmosClient";
|
||||
import { ResourceType } from "@azure/cosmos/dist-esm/common/constants";
|
||||
import { config, Platform } from "../Config";
|
||||
import { configContext, Platform, updateConfigContext, resetConfigContext } from "../ConfigContext";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
import { endpoint, getTokenFromAuthService, requestPlugin, tokenProvider } from "./CosmosClient";
|
||||
|
||||
describe("tokenProvider", () => {
|
||||
const options = {
|
||||
|
@ -32,7 +33,9 @@ describe("tokenProvider", () => {
|
|||
});
|
||||
|
||||
it("does not call the auth service if a master key is set", async () => {
|
||||
CosmosClient.masterKey("foo");
|
||||
updateUserContext({
|
||||
masterKey: "foo"
|
||||
});
|
||||
await tokenProvider(options);
|
||||
expect((window.fetch as any).mock.calls.length).toBe(0);
|
||||
});
|
||||
|
@ -41,7 +44,7 @@ describe("tokenProvider", () => {
|
|||
describe("getTokenFromAuthService", () => {
|
||||
beforeEach(() => {
|
||||
delete window.dataExplorer;
|
||||
delete config.BACKEND_ENDPOINT;
|
||||
resetConfigContext();
|
||||
window.fetch = jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
json: () => "{}",
|
||||
|
@ -64,7 +67,9 @@ describe("getTokenFromAuthService", () => {
|
|||
});
|
||||
|
||||
it("builds the correct URL in dev", () => {
|
||||
config.BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://localhost:1234"
|
||||
});
|
||||
getTokenFromAuthService("GET", "dbs", "foo");
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/guest/runtimeproxy/authorizationTokens",
|
||||
|
@ -75,24 +80,28 @@ describe("getTokenFromAuthService", () => {
|
|||
|
||||
describe("endpoint", () => {
|
||||
it("falls back to _databaseAccount", () => {
|
||||
CosmosClient.databaseAccount({
|
||||
id: "foo",
|
||||
name: "foo",
|
||||
location: "foo",
|
||||
type: "foo",
|
||||
kind: "foo",
|
||||
tags: [],
|
||||
properties: {
|
||||
documentEndpoint: "bar",
|
||||
gremlinEndpoint: "foo",
|
||||
tableEndpoint: "foo",
|
||||
cassandraEndpoint: "foo"
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
id: "foo",
|
||||
name: "foo",
|
||||
location: "foo",
|
||||
type: "foo",
|
||||
kind: "foo",
|
||||
tags: [],
|
||||
properties: {
|
||||
documentEndpoint: "bar",
|
||||
gremlinEndpoint: "foo",
|
||||
tableEndpoint: "foo",
|
||||
cassandraEndpoint: "foo"
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(endpoint()).toEqual("bar");
|
||||
});
|
||||
it("uses _endpoint if set", () => {
|
||||
CosmosClient.endpoint("baz");
|
||||
updateUserContext({
|
||||
endpoint: "baz"
|
||||
});
|
||||
expect(endpoint()).toEqual("baz");
|
||||
});
|
||||
});
|
||||
|
@ -100,17 +109,17 @@ describe("endpoint", () => {
|
|||
describe("requestPlugin", () => {
|
||||
beforeEach(() => {
|
||||
delete window.dataExplorerPlatform;
|
||||
delete config.PROXY_PATH;
|
||||
delete config.BACKEND_ENDPOINT;
|
||||
delete config.PROXY_PATH;
|
||||
resetConfigContext();
|
||||
});
|
||||
|
||||
describe("Hosted", () => {
|
||||
it("builds a proxy URL in development", () => {
|
||||
const next = jest.fn();
|
||||
config.platform = Platform.Hosted;
|
||||
config.BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
config.PROXY_PATH = "/proxy";
|
||||
updateConfigContext({
|
||||
platform: Platform.Hosted,
|
||||
BACKEND_ENDPOINT: "https://localhost:1234",
|
||||
PROXY_PATH: "/proxy"
|
||||
});
|
||||
const headers = {};
|
||||
const endpoint = "https://docs.azure.com";
|
||||
const path = "/dbs/foo";
|
||||
|
@ -122,8 +131,7 @@ describe("requestPlugin", () => {
|
|||
describe("Emulator", () => {
|
||||
it("builds a url for emulator proxy via webpack", () => {
|
||||
const next = jest.fn();
|
||||
config.platform = Platform.Emulator;
|
||||
config.PROXY_PATH = "/proxy";
|
||||
updateConfigContext({ platform: Platform.Emulator, PROXY_PATH: "/proxy" });
|
||||
const headers = {};
|
||||
const endpoint = "";
|
||||
const path = "/dbs/foo";
|
||||
|
|
|
@ -1,39 +1,28 @@
|
|||
import * as Cosmos from "@azure/cosmos";
|
||||
import { RequestInfo, setAuthorizationTokenHeaderUsingMasterKey } from "@azure/cosmos";
|
||||
import { DatabaseAccount } from "../Contracts/DataModels";
|
||||
import { HttpHeaders, EmulatorMasterKey } from "./Constants";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { config, Platform } from "../Config";
|
||||
|
||||
let _client: Cosmos.CosmosClient;
|
||||
let _masterKey: string;
|
||||
let _endpoint: string;
|
||||
let _authorizationToken: string;
|
||||
let _accessToken: string;
|
||||
let _databaseAccount: DatabaseAccount;
|
||||
let _subscriptionId: string;
|
||||
let _resourceGroup: string;
|
||||
let _resourceToken: string;
|
||||
import { configContext, Platform } from "../ConfigContext";
|
||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
const _global = typeof self === "undefined" ? window : self;
|
||||
|
||||
export const tokenProvider = async (requestInfo: RequestInfo) => {
|
||||
const { verb, resourceId, resourceType, headers } = requestInfo;
|
||||
if (config.platform === Platform.Emulator) {
|
||||
if (configContext.platform === Platform.Emulator) {
|
||||
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||
await setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, EmulatorMasterKey);
|
||||
return decodeURIComponent(headers.authorization);
|
||||
}
|
||||
|
||||
if (_masterKey) {
|
||||
if (userContext.masterKey) {
|
||||
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||
await setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, EmulatorMasterKey);
|
||||
return decodeURIComponent(headers.authorization);
|
||||
}
|
||||
|
||||
if (_resourceToken) {
|
||||
return _resourceToken;
|
||||
if (userContext.resourceToken) {
|
||||
return userContext.resourceToken;
|
||||
}
|
||||
|
||||
const result = await getTokenFromAuthService(verb, resourceType, resourceId);
|
||||
|
@ -42,28 +31,33 @@ export const tokenProvider = async (requestInfo: RequestInfo) => {
|
|||
};
|
||||
|
||||
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, next) => {
|
||||
requestContext.endpoint = config.PROXY_PATH;
|
||||
requestContext.endpoint = configContext.PROXY_PATH;
|
||||
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
||||
return next(requestContext);
|
||||
};
|
||||
|
||||
export const endpoint = () => {
|
||||
if (config.platform === Platform.Emulator) {
|
||||
if (configContext.platform === Platform.Emulator) {
|
||||
// In worker scope, _global(self).parent does not exist
|
||||
const location = _global.parent ? _global.parent.location : _global.location;
|
||||
return config.EMULATOR_ENDPOINT || location.origin;
|
||||
return configContext.EMULATOR_ENDPOINT || location.origin;
|
||||
}
|
||||
return _endpoint || (_databaseAccount && _databaseAccount.properties && _databaseAccount.properties.documentEndpoint);
|
||||
return (
|
||||
userContext.endpoint ||
|
||||
(userContext.databaseAccount &&
|
||||
userContext.databaseAccount.properties &&
|
||||
userContext.databaseAccount.properties.documentEndpoint)
|
||||
);
|
||||
};
|
||||
|
||||
export async function getTokenFromAuthService(verb: string, resourceType: string, resourceId?: string): Promise<any> {
|
||||
try {
|
||||
const host = config.BACKEND_ENDPOINT || _global.dataExplorer.extensionEndpoint();
|
||||
const host = configContext.BACKEND_ENDPOINT || _global.dataExplorer.extensionEndpoint();
|
||||
const response = await _global.fetch(host + "/api/guest/runtimeproxy/authorizationTokens", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"x-ms-encrypted-auth-token": _accessToken
|
||||
"x-ms-encrypted-auth-token": userContext.accessToken
|
||||
},
|
||||
body: JSON.stringify({
|
||||
verb,
|
||||
|
@ -75,106 +69,25 @@ export async function getTokenFromAuthService(verb: string, resourceType: string
|
|||
const result = JSON.parse(await response.json());
|
||||
return result;
|
||||
} catch (error) {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Failed to get authorization headers for ${resourceType}: ${JSON.stringify(error)}`
|
||||
);
|
||||
logConsoleError(`Failed to get authorization headers for ${resourceType}: ${JSON.stringify(error)}`);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const CosmosClient = {
|
||||
client(): Cosmos.CosmosClient {
|
||||
if (_client) {
|
||||
return _client;
|
||||
}
|
||||
const options: Cosmos.CosmosClientOptions = {
|
||||
endpoint: endpoint() || " ", // CosmosClient gets upset if we pass a falsy value here
|
||||
key: _masterKey,
|
||||
tokenProvider,
|
||||
connectionPolicy: {
|
||||
enableEndpointDiscovery: false
|
||||
},
|
||||
userAgentSuffix: "Azure Portal"
|
||||
};
|
||||
export function client(): Cosmos.CosmosClient {
|
||||
const options: Cosmos.CosmosClientOptions = {
|
||||
endpoint: endpoint() || " ", // CosmosClient gets upset if we pass a falsy value here
|
||||
key: userContext.masterKey,
|
||||
tokenProvider,
|
||||
connectionPolicy: {
|
||||
enableEndpointDiscovery: false
|
||||
},
|
||||
userAgentSuffix: "Azure Portal"
|
||||
};
|
||||
|
||||
// In development we proxy requests to the backend via webpack. This is removed in production bundles.
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
(options as any).plugins = [{ on: "request", plugin: requestPlugin }];
|
||||
}
|
||||
_client = new Cosmos.CosmosClient(options);
|
||||
return _client;
|
||||
},
|
||||
|
||||
authorizationToken(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _authorizationToken;
|
||||
}
|
||||
_authorizationToken = value;
|
||||
_client = null;
|
||||
return value;
|
||||
},
|
||||
|
||||
accessToken(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _accessToken;
|
||||
}
|
||||
_accessToken = value;
|
||||
_client = null;
|
||||
return value;
|
||||
},
|
||||
|
||||
masterKey(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _masterKey;
|
||||
}
|
||||
_client = null;
|
||||
_masterKey = value;
|
||||
return value;
|
||||
},
|
||||
|
||||
endpoint(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _endpoint;
|
||||
}
|
||||
_client = null;
|
||||
_endpoint = value;
|
||||
return value;
|
||||
},
|
||||
|
||||
databaseAccount(value?: DatabaseAccount): DatabaseAccount {
|
||||
if (typeof value === "undefined") {
|
||||
return _databaseAccount || ({} as any);
|
||||
}
|
||||
_client = null;
|
||||
_databaseAccount = value;
|
||||
return value;
|
||||
},
|
||||
|
||||
subscriptionId(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _subscriptionId;
|
||||
}
|
||||
_client = null;
|
||||
_subscriptionId = value;
|
||||
return value;
|
||||
},
|
||||
|
||||
resourceGroup(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _resourceGroup;
|
||||
}
|
||||
_client = null;
|
||||
_resourceGroup = value;
|
||||
return value;
|
||||
},
|
||||
|
||||
resourceToken(value?: string): string {
|
||||
if (typeof value === "undefined") {
|
||||
return _resourceToken;
|
||||
}
|
||||
_client = null;
|
||||
_resourceToken = value;
|
||||
return value;
|
||||
// In development we proxy requests to the backend via webpack. This is removed in production bundles.
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
(options as any).plugins = [{ on: "request", plugin: requestPlugin }];
|
||||
}
|
||||
};
|
||||
return new Cosmos.CosmosClient(options);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
TriggerDefinition
|
||||
} from "@azure/cosmos";
|
||||
import { ContainerRequest } from "@azure/cosmos/dist-esm/client/Container/ContainerRequest";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { client } from "./CosmosClient";
|
||||
import { DatabaseRequest } from "@azure/cosmos/dist-esm/client/Database/DatabaseRequest";
|
||||
import { LocalStorageUtility, StorageKey } from "../Shared/StorageUtility";
|
||||
import { sendCachedDataMessage } from "./MessageHandler";
|
||||
|
@ -25,7 +25,7 @@ import { MessageTypes } from "../Contracts/ExplorerContracts";
|
|||
import { OfferUtils } from "../Utils/OfferUtils";
|
||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
|
||||
import { Platform, config } from "../Config";
|
||||
import { Platform, configContext } from "../ConfigContext";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import ConflictId from "../Explorer/Tree/ConflictId";
|
||||
|
@ -54,7 +54,7 @@ export function queryDocuments(
|
|||
options: any
|
||||
): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||
options = getCommonQueryOptions(options);
|
||||
const documentsIterator = CosmosClient.client()
|
||||
const documentsIterator = client()
|
||||
.database(databaseId)
|
||||
.container(containerId)
|
||||
.items.query(query, options);
|
||||
|
@ -66,7 +66,7 @@ export function readStoredProcedures(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.StoredProcedure[]> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedures.readAll(options)
|
||||
|
@ -81,7 +81,7 @@ export function readStoredProcedure(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.StoredProcedure> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedure(requestedResource.id)
|
||||
|
@ -94,7 +94,7 @@ export function readUserDefinedFunctions(
|
|||
options: any
|
||||
): Q.Promise<DataModels.UserDefinedFunction[]> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.userDefinedFunctions.readAll(options)
|
||||
|
@ -108,7 +108,7 @@ export function readUserDefinedFunction(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.UserDefinedFunction> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.userDefinedFunction(requestedResource.id)
|
||||
|
@ -119,7 +119,7 @@ export function readUserDefinedFunction(
|
|||
|
||||
export function readTriggers(collection: ViewModels.Collection, options: any): Q.Promise<DataModels.Trigger[]> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.triggers.readAll(options)
|
||||
|
@ -134,7 +134,7 @@ export function readTrigger(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.Trigger> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.trigger(requestedResource.id)
|
||||
|
@ -152,7 +152,7 @@ export function executeStoredProcedure(
|
|||
// TODO remove this deferred. Kept it because of timeout code at bottom of function
|
||||
const deferred = Q.defer<any>();
|
||||
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedure(storedProcedure.id())
|
||||
|
@ -175,7 +175,7 @@ export function readDocument(collection: ViewModels.CollectionBase, documentId:
|
|||
const partitionKey = documentId.partitionKeyValue;
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.item(documentId.id(), partitionKey)
|
||||
|
@ -210,7 +210,7 @@ export function updateCollection(
|
|||
options: any = {}
|
||||
): Q.Promise<DataModels.Collection> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(databaseId)
|
||||
.container(collectionId)
|
||||
.replace(newCollection as ContainerDefinition, options)
|
||||
|
@ -228,7 +228,7 @@ export function updateDocument(
|
|||
const partitionKey = documentId.partitionKeyValue;
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.item(documentId.id(), partitionKey)
|
||||
|
@ -243,7 +243,7 @@ export function updateOffer(
|
|||
options?: RequestOptions
|
||||
): Q.Promise<DataModels.Offer> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.offer(offer.id)
|
||||
.replace(newOffer, options)
|
||||
.then(response => {
|
||||
|
@ -258,7 +258,7 @@ export function updateStoredProcedure(
|
|||
options: any
|
||||
): Q.Promise<DataModels.StoredProcedure> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedure(storedProcedure.id)
|
||||
|
@ -273,7 +273,7 @@ export function updateUserDefinedFunction(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.UserDefinedFunction> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.userDefinedFunction(userDefinedFunction.id)
|
||||
|
@ -288,7 +288,7 @@ export function updateTrigger(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.Trigger> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.trigger(trigger.id)
|
||||
|
@ -299,7 +299,7 @@ export function updateTrigger(
|
|||
|
||||
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Q.Promise<any> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.items.create(newDocument)
|
||||
|
@ -313,7 +313,7 @@ export function createStoredProcedure(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.StoredProcedure> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedures.create(newStoredProcedure, options)
|
||||
|
@ -327,7 +327,7 @@ export function createUserDefinedFunction(
|
|||
options: any
|
||||
): Q.Promise<DataModels.UserDefinedFunction> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.userDefinedFunctions.create(newUserDefinedFunction, options)
|
||||
|
@ -341,7 +341,7 @@ export function createTrigger(
|
|||
options?: any
|
||||
): Q.Promise<DataModels.Trigger> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.triggers.create(newTrigger as TriggerDefinition, options)
|
||||
|
@ -353,7 +353,7 @@ export function deleteDocument(collection: ViewModels.CollectionBase, documentId
|
|||
const partitionKey = documentId.partitionKeyValue;
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.item(documentId.id(), partitionKey)
|
||||
|
@ -369,7 +369,7 @@ export function deleteConflict(
|
|||
options.partitionKey = options.partitionKey || getPartitionKeyHeaderForConflict(conflictId);
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.conflict(conflictId.id())
|
||||
|
@ -383,7 +383,7 @@ export function deleteStoredProcedure(
|
|||
options: any
|
||||
): Q.Promise<any> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.storedProcedure(storedProcedure.id)
|
||||
|
@ -397,7 +397,7 @@ export function deleteUserDefinedFunction(
|
|||
options: any
|
||||
): Q.Promise<any> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.userDefinedFunction(userDefinedFunction.id)
|
||||
|
@ -411,7 +411,7 @@ export function deleteTrigger(
|
|||
options: any
|
||||
): Q.Promise<any> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.scripts.trigger(trigger.id)
|
||||
|
@ -421,7 +421,7 @@ export function deleteTrigger(
|
|||
|
||||
export function readCollections(database: ViewModels.Database, options: any): Q.Promise<DataModels.Collection[]> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(database.id())
|
||||
.containers.readAll()
|
||||
.fetchAll()
|
||||
|
@ -431,7 +431,7 @@ export function readCollections(database: ViewModels.Database, options: any): Q.
|
|||
|
||||
export function readCollection(databaseId: string, collectionId: string): Q.Promise<DataModels.Collection> {
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(databaseId)
|
||||
.container(collectionId)
|
||||
.read()
|
||||
|
@ -449,7 +449,7 @@ export function readCollectionQuotaInfo(
|
|||
options.initialHeaders[Constants.HttpHeaders.populatePartitionStatistics] = true;
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(collection.databaseId)
|
||||
.container(collection.id())
|
||||
.read(options)
|
||||
|
@ -476,7 +476,7 @@ export function readCollectionQuotaInfo(
|
|||
|
||||
export function readOffers(options: any): Q.Promise<DataModels.Offer[]> {
|
||||
try {
|
||||
if (config.platform === Platform.Portal) {
|
||||
if (configContext.platform === Platform.Portal) {
|
||||
return sendCachedDataMessage<DataModels.Offer[]>(MessageTypes.AllOffers, [
|
||||
(<any>window).dataExplorer.databaseAccount().id,
|
||||
Constants.ClientDefaults.portalCacheTimeoutMs
|
||||
|
@ -486,7 +486,7 @@ export function readOffers(options: any): Q.Promise<DataModels.Offer[]> {
|
|||
// If error getting cached Offers, continue on and read via SDK
|
||||
}
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.offers.readAll()
|
||||
.fetchAll()
|
||||
.then(response => response.resources)
|
||||
|
@ -501,7 +501,7 @@ export function readOffer(requestedResource: DataModels.Offer, options: any): Q.
|
|||
}
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.offer(requestedResource.id)
|
||||
.read(options)
|
||||
.then(response => ({ ...response.resource, headers: response.headers }))
|
||||
|
@ -510,7 +510,7 @@ export function readOffer(requestedResource: DataModels.Offer, options: any): Q.
|
|||
|
||||
export function readDatabases(options: any): Q.Promise<DataModels.Database[]> {
|
||||
try {
|
||||
if (config.platform === Platform.Portal) {
|
||||
if (configContext.platform === Platform.Portal) {
|
||||
return sendCachedDataMessage<DataModels.Database[]>(MessageTypes.AllDatabases, [
|
||||
(<any>window).dataExplorer.databaseAccount().id,
|
||||
Constants.ClientDefaults.portalCacheTimeoutMs
|
||||
|
@ -521,7 +521,7 @@ export function readDatabases(options: any): Q.Promise<DataModels.Database[]> {
|
|||
}
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.databases.readAll()
|
||||
.fetchAll()
|
||||
.then(response => response.resources as DataModels.Database[])
|
||||
|
@ -569,7 +569,7 @@ export function getOrCreateDatabaseAndCollection(
|
|||
}
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.databases.createIfNotExists(createBody, databaseOptions)
|
||||
.then(response => {
|
||||
return response.database.containers.create(
|
||||
|
@ -612,7 +612,7 @@ export function createDatabase(
|
|||
}
|
||||
|
||||
export function refreshCachedOffers(): Q.Promise<void> {
|
||||
if (config.platform === Platform.Portal) {
|
||||
if (configContext.platform === Platform.Portal) {
|
||||
return sendCachedDataMessage(MessageTypes.RefreshOffers, []);
|
||||
} else {
|
||||
return Q();
|
||||
|
@ -620,7 +620,7 @@ export function refreshCachedOffers(): Q.Promise<void> {
|
|||
}
|
||||
|
||||
export function refreshCachedResources(options?: any): Q.Promise<void> {
|
||||
if (config.platform === Platform.Portal) {
|
||||
if (configContext.platform === Platform.Portal) {
|
||||
return sendCachedDataMessage(MessageTypes.RefreshResources, []);
|
||||
} else {
|
||||
return Q();
|
||||
|
@ -633,7 +633,7 @@ export function queryConflicts(
|
|||
query: string,
|
||||
options: any
|
||||
): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||
const documentsIterator = CosmosClient.client()
|
||||
const documentsIterator = client()
|
||||
.database(databaseId)
|
||||
.container(containerId)
|
||||
.conflicts.query(query, options);
|
||||
|
@ -643,7 +643,7 @@ export function queryConflicts(
|
|||
export async function updateOfferThroughputBeyondLimit(
|
||||
request: DataModels.UpdateOfferThroughputRequest
|
||||
): Promise<void> {
|
||||
if (config.platform !== Platform.Portal) {
|
||||
if (configContext.platform !== Platform.Portal) {
|
||||
throw new Error("Updating throughput beyond specified limit is not supported on this platform");
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ function _createDatabase(request: DataModels.CreateDatabaseRequest, options: any
|
|||
}
|
||||
|
||||
return Q(
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.databases.create(createBody, databaseOptions)
|
||||
.then((response: DatabaseResponse) => {
|
||||
return refreshCachedResources(databaseOptions).then(() => response.resource);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import { AuthType } from "../AuthType";
|
||||
import { configContext, resetConfigContext, updateConfigContext } from "../ConfigContext";
|
||||
import { DatabaseAccount } from "../Contracts/DataModels";
|
||||
import { Collection } from "../Contracts/ViewModels";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
import {
|
||||
_createMongoCollectionWithARM,
|
||||
deleteDocument,
|
||||
getEndpoint,
|
||||
queryDocuments,
|
||||
readDocument,
|
||||
updateDocument
|
||||
updateDocument,
|
||||
_createMongoCollectionWithARM
|
||||
} from "./MongoProxyClient";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { Collection } from "../Contracts/ViewModels";
|
||||
import { config } from "../Config";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import { DatabaseAccount } from "../Contracts/DataModels";
|
||||
jest.mock("../ResourceProvider/ResourceProviderClient.ts");
|
||||
|
||||
const databaseId = "testDB";
|
||||
|
@ -62,13 +62,15 @@ const databaseAccount = {
|
|||
tableEndpoint: "foo",
|
||||
cassandraEndpoint: "foo"
|
||||
}
|
||||
};
|
||||
} as DatabaseAccount;
|
||||
|
||||
describe("MongoProxyClient", () => {
|
||||
describe("queryDocuments", () => {
|
||||
beforeEach(() => {
|
||||
delete config.BACKEND_ENDPOINT;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
resetConfigContext();
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -88,7 +90,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("builds the correct proxy URL in development", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
queryDocuments(databaseId, collection, true, "{}");
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/mongo/explorer/resourcelist?db=testDB&coll=testCollection&resourceUrl=bardbs%2FtestDB%2Fcolls%2FtestCollection%2Fdocs%2F&rid=testCollectionrid&rtype=docs&sid=&rg=&dba=foo&pk=pk",
|
||||
|
@ -98,8 +100,10 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
describe("readDocument", () => {
|
||||
beforeEach(() => {
|
||||
delete config.MONGO_BACKEND_ENDPOINT;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
resetConfigContext();
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -119,7 +123,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("builds the correct proxy URL in development", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
readDocument(databaseId, collection, documentId);
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk",
|
||||
|
@ -129,8 +133,10 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
describe("createDocument", () => {
|
||||
beforeEach(() => {
|
||||
delete config.MONGO_BACKEND_ENDPOINT;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
resetConfigContext();
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -150,7 +156,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("builds the correct proxy URL in development", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
readDocument(databaseId, collection, documentId);
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk",
|
||||
|
@ -160,8 +166,10 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
describe("updateDocument", () => {
|
||||
beforeEach(() => {
|
||||
delete config.MONGO_BACKEND_ENDPOINT;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
resetConfigContext();
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -181,7 +189,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("builds the correct proxy URL in development", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
updateDocument(databaseId, collection, documentId, "{}");
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2Fdocs%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk",
|
||||
|
@ -191,8 +199,10 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
describe("deleteDocument", () => {
|
||||
beforeEach(() => {
|
||||
delete config.MONGO_BACKEND_ENDPOINT;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
resetConfigContext();
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -212,7 +222,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("builds the correct proxy URL in development", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
deleteDocument(databaseId, collection, documentId);
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://localhost:1234/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2Fdocs%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk",
|
||||
|
@ -222,9 +232,11 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
describe("getEndpoint", () => {
|
||||
beforeEach(() => {
|
||||
delete config.MONGO_BACKEND_ENDPOINT;
|
||||
resetConfigContext();
|
||||
delete window.authType;
|
||||
CosmosClient.databaseAccount(databaseAccount as any);
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
|
@ -237,7 +249,7 @@ describe("MongoProxyClient", () => {
|
|||
});
|
||||
|
||||
it("returns a development endpoint", () => {
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234";
|
||||
updateConfigContext({ MONGO_BACKEND_ENDPOINT: "https://localhost:1234" });
|
||||
const endpoint = getEndpoint(databaseAccount as DatabaseAccount);
|
||||
expect(endpoint).toEqual("https://localhost:1234/api/mongo/explorer");
|
||||
});
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import { Constants as CosmosSDKConstants } from "@azure/cosmos";
|
||||
import queryString from "querystring";
|
||||
import { AuthType } from "../AuthType";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as DataExplorerConstants from "../Common/Constants";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import EnvironmentUtility from "./EnvironmentUtility";
|
||||
import queryString from "querystring";
|
||||
import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
|
||||
import { ApiType, HttpHeaders, HttpStatusCodes } from "./Constants";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { Collection } from "../Contracts/ViewModels";
|
||||
import { config } from "../Config";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { Constants as CosmosSDKConstants } from "@azure/cosmos";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { sendMessage } from "./MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import { MinimalQueryIterator } from "./IteratorUtilities";
|
||||
import { Collection } from "../Contracts/ViewModels";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { ApiType, HttpHeaders, HttpStatusCodes } from "./Constants";
|
||||
import { userContext } from "../UserContext";
|
||||
import EnvironmentUtility from "./EnvironmentUtility";
|
||||
import { MinimalQueryIterator } from "./IteratorUtilities";
|
||||
import { sendMessage } from "./MessageHandler";
|
||||
|
||||
const defaultHeaders = {
|
||||
[HttpHeaders.apiType]: ApiType.MongoDB.toString(),
|
||||
|
@ -26,9 +26,9 @@ const defaultHeaders = {
|
|||
|
||||
function authHeaders() {
|
||||
if (window.authType === AuthType.EncryptedToken) {
|
||||
return { [HttpHeaders.guestAccessToken]: CosmosClient.accessToken() };
|
||||
return { [HttpHeaders.guestAccessToken]: userContext.accessToken };
|
||||
} else {
|
||||
return { [HttpHeaders.authorization]: CosmosClient.authorizationToken() };
|
||||
return { [HttpHeaders.authorization]: userContext.authorizationToken };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ export function queryDocuments(
|
|||
query: string,
|
||||
continuationToken?: string
|
||||
): Promise<QueryResponse> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint;
|
||||
const params = {
|
||||
db: databaseId,
|
||||
|
@ -75,8 +75,8 @@ export function queryDocuments(
|
|||
resourceUrl: `${resourceEndpoint}dbs/${databaseId}/colls/${collection.id()}/docs/`,
|
||||
rid: collection.rid,
|
||||
rtype: "docs",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
pk:
|
||||
collection && collection.partitionKey && !collection.partitionKey.systemKey ? collection.partitionKeyProperty : ""
|
||||
|
@ -125,7 +125,7 @@ export function readDocument(
|
|||
collection: Collection,
|
||||
documentId: DocumentId
|
||||
): Promise<DataModels.DocumentId> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint;
|
||||
const idComponents = documentId.self.split("/");
|
||||
const path = idComponents.slice(0, 4).join("/");
|
||||
|
@ -136,8 +136,8 @@ export function readDocument(
|
|||
resourceUrl: `${resourceEndpoint}${path}/${rid}`,
|
||||
rid,
|
||||
rtype: "docs",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
pk:
|
||||
documentId && documentId.partitionKey && !documentId.partitionKey.systemKey ? documentId.partitionKeyProperty : ""
|
||||
|
@ -169,7 +169,7 @@ export function createDocument(
|
|||
partitionKeyProperty: string,
|
||||
documentContent: unknown
|
||||
): Promise<DataModels.DocumentId> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint;
|
||||
const params = {
|
||||
db: databaseId,
|
||||
|
@ -177,8 +177,8 @@ export function createDocument(
|
|||
resourceUrl: `${resourceEndpoint}dbs/${databaseId}/colls/${collection.id()}/docs/`,
|
||||
rid: collection.rid,
|
||||
rtype: "docs",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
pk: collection && collection.partitionKey && !collection.partitionKey.systemKey ? partitionKeyProperty : ""
|
||||
};
|
||||
|
@ -208,7 +208,7 @@ export function updateDocument(
|
|||
documentId: DocumentId,
|
||||
documentContent: string
|
||||
): Promise<DataModels.DocumentId> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint;
|
||||
const idComponents = documentId.self.split("/");
|
||||
const path = idComponents.slice(0, 5).join("/");
|
||||
|
@ -219,8 +219,8 @@ export function updateDocument(
|
|||
resourceUrl: `${resourceEndpoint}${path}/${rid}`,
|
||||
rid,
|
||||
rtype: "docs",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
pk:
|
||||
documentId && documentId.partitionKey && !documentId.partitionKey.systemKey ? documentId.partitionKeyProperty : ""
|
||||
|
@ -247,7 +247,7 @@ export function updateDocument(
|
|||
}
|
||||
|
||||
export function deleteDocument(databaseId: string, collection: Collection, documentId: DocumentId): Promise<void> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint;
|
||||
const idComponents = documentId.self.split("/");
|
||||
const path = idComponents.slice(0, 5).join("/");
|
||||
|
@ -258,8 +258,8 @@ export function deleteDocument(databaseId: string, collection: Collection, docum
|
|||
resourceUrl: `${resourceEndpoint}${path}/${rid}`,
|
||||
rid,
|
||||
rtype: "docs",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
pk:
|
||||
documentId && documentId.partitionKey && !documentId.partitionKey.systemKey ? documentId.partitionKeyProperty : ""
|
||||
|
@ -294,7 +294,7 @@ export function createMongoCollectionWithProxy(
|
|||
isSharded: boolean,
|
||||
autopilotOptions?: DataModels.RpOptions
|
||||
): Promise<DataModels.Collection> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const params: DataModels.MongoParameters = {
|
||||
resourceUrl: databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint,
|
||||
db: databaseId,
|
||||
|
@ -306,8 +306,8 @@ export function createMongoCollectionWithProxy(
|
|||
is: isSharded,
|
||||
rid: "",
|
||||
rtype: "colls",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
isAutoPilot: false
|
||||
};
|
||||
|
@ -351,7 +351,7 @@ export function createMongoCollectionWithARM(
|
|||
isSharded: boolean,
|
||||
additionalOptions?: DataModels.RpOptions
|
||||
): Promise<DataModels.CreateCollectionWithRpResponse> {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const params: DataModels.MongoParameters = {
|
||||
resourceUrl: databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint,
|
||||
db: databaseId,
|
||||
|
@ -363,8 +363,8 @@ export function createMongoCollectionWithARM(
|
|||
is: isSharded,
|
||||
rid: "",
|
||||
rtype: "colls",
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: databaseAccount.name,
|
||||
analyticalStorageTtl
|
||||
};
|
||||
|
@ -384,8 +384,8 @@ export function createMongoCollectionWithARM(
|
|||
export function getEndpoint(databaseAccount: DataModels.DatabaseAccount): string {
|
||||
const serverId = window.dataExplorer.serverId();
|
||||
const extensionEndpoint = window.dataExplorer.extensionEndpoint();
|
||||
let url = config.MONGO_BACKEND_ENDPOINT
|
||||
? config.MONGO_BACKEND_ENDPOINT + "/api/mongo/explorer"
|
||||
let url = configContext.MONGO_BACKEND_ENDPOINT
|
||||
? configContext.MONGO_BACKEND_ENDPOINT + "/api/mongo/explorer"
|
||||
: EnvironmentUtility.getMongoBackendEndpoint(serverId, databaseAccount.location, extensionEndpoint);
|
||||
|
||||
if (window.authType === AuthType.EncryptedToken) {
|
||||
|
@ -411,9 +411,7 @@ async function errorHandling(response: Response, action: string, params: unknown
|
|||
}
|
||||
|
||||
export function getARMCreateCollectionEndpoint(params: DataModels.MongoParameters): string {
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${
|
||||
CosmosClient.databaseAccount().name
|
||||
}/mongodbDatabases/${params.db}/collections/${params.coll}`;
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${userContext.databaseAccount.name}/mongodbDatabases/${params.db}/collections/${params.coll}`;
|
||||
}
|
||||
|
||||
export async function _createMongoCollectionWithARM(
|
||||
|
|
|
@ -2,9 +2,8 @@ import "jquery";
|
|||
import * as Q from "q";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class NotificationsClientBase {
|
||||
private _extensionEndpoint: string;
|
||||
|
@ -16,10 +15,10 @@ export class NotificationsClientBase {
|
|||
|
||||
public fetchNotifications(): Q.Promise<DataModels.Notification[]> {
|
||||
const deferred: Q.Deferred<DataModels.Notification[]> = Q.defer<DataModels.Notification[]>();
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const subscriptionId: string = CosmosClient.subscriptionId();
|
||||
const resourceGroup: string = CosmosClient.resourceGroup();
|
||||
const url: string = `${this._extensionEndpoint}${this._notificationsApiSuffix}?accountName=${databaseAccount.name}&subscriptionId=${subscriptionId}&resourceGroup=${resourceGroup}`;
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
const url = `${this._extensionEndpoint}${this._notificationsApiSuffix}?accountName=${databaseAccount.name}&subscriptionId=${subscriptionId}&resourceGroup=${resourceGroup}`;
|
||||
const authorizationHeader: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||
const headers: any = {};
|
||||
headers[authorizationHeader.header] = authorizationHeader.token;
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import * as _ from "underscore";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import * as ErrorParserUtility from "./ErrorParserUtility";
|
||||
import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import * as Logger from "./Logger";
|
||||
import DocumentsTab from "../Explorer/Tabs/DocumentsTab";
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { QueryUtils } from "../Utils/QueryUtils";
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
||||
import { userContext } from "../UserContext";
|
||||
import {
|
||||
getOrCreateDatabaseAndCollection,
|
||||
createDocument,
|
||||
deleteDocument,
|
||||
getOrCreateDatabaseAndCollection,
|
||||
queryDocuments,
|
||||
queryDocumentsPage,
|
||||
deleteDocument
|
||||
queryDocumentsPage
|
||||
} from "./DocumentClientUtilityBase";
|
||||
import DocumentsTab from "../Explorer/Tabs/DocumentsTab";
|
||||
import * as ErrorParserUtility from "./ErrorParserUtility";
|
||||
import * as Logger from "./Logger";
|
||||
|
||||
export class QueriesClient {
|
||||
private static readonly PartitionKey: DataModels.PartitionKey = {
|
||||
|
@ -249,10 +249,10 @@ export class QueriesClient {
|
|||
}
|
||||
|
||||
public getResourceId(): string {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const databaseAccountName: string = (databaseAccount && databaseAccount.name) || "";
|
||||
const subscriptionId: string = CosmosClient.subscriptionId() || "";
|
||||
const resourceGroup: string = CosmosClient.resourceGroup() || "";
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const databaseAccountName = (databaseAccount && databaseAccount.name) || "";
|
||||
const subscriptionId = userContext.subscriptionId || "";
|
||||
const resourceGroup = userContext.resourceGroup || "";
|
||||
|
||||
return `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/${databaseAccountName}`;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,18 @@ jest.mock("../MessageHandler");
|
|||
import { deleteCollection } from "./deleteCollection";
|
||||
import { armRequest } from "../../Utils/arm/request";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import { DatabaseAccount } from "../../Contracts/DataModels";
|
||||
import { sendCachedDataMessage } from "../MessageHandler";
|
||||
|
||||
describe("deleteCollection", () => {
|
||||
it("should call ARM if logged in with AAD", async () => {
|
||||
window.authType = AuthType.AAD;
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
name: "test"
|
||||
} as DatabaseAccount
|
||||
});
|
||||
(sendCachedDataMessage as jest.Mock).mockResolvedValue(undefined);
|
||||
await deleteCollection("database", "collection");
|
||||
expect(armRequest).toHaveBeenCalled();
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
import { CosmosClient } from "../CosmosClient";
|
||||
import { refreshCachedResources } from "../DataAccessUtilityBase";
|
||||
import { logConsoleProgress, logConsoleInfo, logConsoleError } from "../../Utils/NotificationConsoleUtils";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import { deleteSqlContainer } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
||||
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { client } from "../CosmosClient";
|
||||
import { refreshCachedResources } from "../DataAccessUtilityBase";
|
||||
|
||||
export async function deleteCollection(databaseId: string, collectionId: string): Promise<void> {
|
||||
const clearMessage = logConsoleProgress(`Deleting container ${collectionId}`);
|
||||
try {
|
||||
if (window.authType === AuthType.AAD) {
|
||||
await deleteSqlContainer(
|
||||
CosmosClient.subscriptionId(),
|
||||
CosmosClient.resourceGroup(),
|
||||
CosmosClient.databaseAccount().name,
|
||||
userContext.subscriptionId,
|
||||
userContext.resourceGroup,
|
||||
userContext.databaseAccount.name,
|
||||
databaseId,
|
||||
collectionId
|
||||
);
|
||||
} else {
|
||||
await CosmosClient.client()
|
||||
await client()
|
||||
.database(databaseId)
|
||||
.container(collectionId)
|
||||
.delete();
|
||||
|
|
|
@ -3,11 +3,18 @@ jest.mock("../MessageHandler");
|
|||
import { deleteDatabase } from "./deleteDatabase";
|
||||
import { armRequest } from "../../Utils/arm/request";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import { DatabaseAccount } from "../../Contracts/DataModels";
|
||||
import { sendCachedDataMessage } from "../MessageHandler";
|
||||
|
||||
describe("deleteDatabase", () => {
|
||||
it("should call ARM if logged in with AAD", async () => {
|
||||
window.authType = AuthType.AAD;
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
name: "test"
|
||||
} as DatabaseAccount
|
||||
});
|
||||
(sendCachedDataMessage as jest.Mock).mockResolvedValue(undefined);
|
||||
await deleteDatabase("database");
|
||||
expect(armRequest).toHaveBeenCalled();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { CosmosClient } from "../CosmosClient";
|
||||
import { refreshCachedResources } from "../DataAccessUtilityBase";
|
||||
import { logConsoleProgress, logConsoleError, logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
||||
import { deleteSqlDatabase } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import { deleteSqlDatabase } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
||||
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { client } from "../CosmosClient";
|
||||
import { refreshCachedResources } from "../DataAccessUtilityBase";
|
||||
import { logError } from "../Logger";
|
||||
import { sendNotificationForError } from "./sendNotificationForError";
|
||||
|
||||
|
@ -12,13 +13,13 @@ export async function deleteDatabase(databaseId: string): Promise<void> {
|
|||
try {
|
||||
if (window.authType === AuthType.AAD) {
|
||||
await deleteSqlDatabase(
|
||||
CosmosClient.subscriptionId(),
|
||||
CosmosClient.resourceGroup(),
|
||||
CosmosClient.databaseAccount().name,
|
||||
userContext.subscriptionId,
|
||||
userContext.resourceGroup,
|
||||
userContext.databaseAccount.name,
|
||||
databaseId
|
||||
);
|
||||
} else {
|
||||
await CosmosClient.client()
|
||||
await client()
|
||||
.database(databaseId)
|
||||
.delete();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ export enum Platform {
|
|||
Emulator = "Emulator"
|
||||
}
|
||||
|
||||
interface Config {
|
||||
interface ConfigContext {
|
||||
platform: Platform;
|
||||
allowedParentFrameOrigins: RegExp;
|
||||
gitSha?: string;
|
||||
|
@ -28,7 +28,7 @@ interface Config {
|
|||
}
|
||||
|
||||
// Default configuration
|
||||
let config: Config = {
|
||||
let configContext: Readonly<ConfigContext> = {
|
||||
platform: Platform.Portal,
|
||||
allowedParentFrameOrigins: /^https:\/\/portal\.azure\.com$|^https:\/\/portal\.azure\.us$|^https:\/\/portal\.azure\.cn$|^https:\/\/portal\.microsoftazure\.de$|^https:\/\/.+\.portal\.azure\.com$|^https:\/\/.+\.portal\.azure\.us$|^https:\/\/.+\.portal\.azure\.cn$|^https:\/\/.+\.portal\.microsoftazure\.de$|^https:\/\/main\.documentdb\.ext\.azure\.com$|^https:\/\/main\.documentdb\.ext\.microsoftazure\.de$|^https:\/\/main\.documentdb\.ext\.azure\.cn$|^https:\/\/main\.documentdb\.ext\.azure\.us$/,
|
||||
// Webpack injects this at build time
|
||||
|
@ -46,22 +46,35 @@ let config: Config = {
|
|||
JUNO_ENDPOINT: "https://tools.cosmos.azure.com"
|
||||
};
|
||||
|
||||
export function resetConfigContext(): void {
|
||||
if (process.env.NODE_ENV !== "test") {
|
||||
throw new Error("resetConfigContext can only becalled in a test environment");
|
||||
}
|
||||
configContext = {} as ConfigContext;
|
||||
}
|
||||
|
||||
export function updateConfigContext(newContext: Partial<ConfigContext>): void {
|
||||
Object.assign(configContext, newContext);
|
||||
}
|
||||
|
||||
// Injected for local develpment. These will be removed in the production bundle by webpack
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
const port: string = process.env.PORT || "1234";
|
||||
config.BACKEND_ENDPOINT = "https://localhost:" + port;
|
||||
config.MONGO_BACKEND_ENDPOINT = "https://localhost:" + port;
|
||||
config.PROXY_PATH = "/proxy";
|
||||
config.EMULATOR_ENDPOINT = "https://localhost:8081";
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://localhost:" + port,
|
||||
MONGO_BACKEND_ENDPOINT: "https://localhost:" + port,
|
||||
PROXY_PATH: "/proxy",
|
||||
EMULATOR_ENDPOINT: "https://localhost:8081"
|
||||
});
|
||||
}
|
||||
|
||||
export async function initializeConfiguration(): Promise<Config> {
|
||||
export async function initializeConfiguration(): Promise<ConfigContext> {
|
||||
try {
|
||||
const response = await fetch("./config.json");
|
||||
if (response.status === 200) {
|
||||
try {
|
||||
const externalConfig = await response.json();
|
||||
config = Object.assign({}, config, externalConfig);
|
||||
Object.assign(configContext, externalConfig);
|
||||
} catch (error) {
|
||||
console.error("Unable to parse json in config file");
|
||||
console.error(error);
|
||||
|
@ -70,12 +83,13 @@ export async function initializeConfiguration(): Promise<Config> {
|
|||
// Allow override of any config value with URL query parameters
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.forEach((value, key) => {
|
||||
(config as any)[key] = value;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(configContext as any)[key] = value;
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("No configuration file found using defaults");
|
||||
}
|
||||
return config;
|
||||
return configContext;
|
||||
}
|
||||
|
||||
export { config };
|
||||
export { configContext };
|
|
@ -4,10 +4,10 @@ import * as sinon from "sinon";
|
|||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import Q from "q";
|
||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import * as DocumentClientUtility from "../../Common/DocumentClientUtilityBase";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
describe("ContainerSampleGenerator", () => {
|
||||
const createExplorerStub = (database: ViewModels.Database): Explorer => {
|
||||
|
@ -75,8 +75,21 @@ describe("ContainerSampleGenerator", () => {
|
|||
sinon.stub(GremlinClient.prototype, "initialize").callsFake(() => {});
|
||||
const executeStub = sinon.stub(GremlinClient.prototype, "execute").returns(Q.resolve());
|
||||
|
||||
sinon.stub(CosmosClient, "databaseAccount").returns({
|
||||
properties: {}
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
id: "foo",
|
||||
name: "foo",
|
||||
location: "foo",
|
||||
type: "foo",
|
||||
kind: "foo",
|
||||
tags: [],
|
||||
properties: {
|
||||
documentEndpoint: "bar",
|
||||
gremlinEndpoint: "foo",
|
||||
tableEndpoint: "foo",
|
||||
cassandraEndpoint: "foo"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const sampleCollectionId = "SampleCollection";
|
||||
|
|
|
@ -3,11 +3,11 @@ import * as DataModels from "../../Contracts/DataModels";
|
|||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import GraphTab from ".././Tabs/GraphTab";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import Explorer from "../Explorer";
|
||||
import { createDocument, getOrCreateDatabaseAndCollection } from "../../Common/DocumentClientUtilityBase";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
interface SampleDataFile extends DataModels.CreateDatabaseAndCollectionRequest {
|
||||
data: any[];
|
||||
|
@ -87,14 +87,14 @@ export class ContainerSampleGenerator {
|
|||
if (!queries || queries.length < 1) {
|
||||
return;
|
||||
}
|
||||
const account = CosmosClient.databaseAccount();
|
||||
const account = userContext.databaseAccount;
|
||||
const databaseId = collection.databaseId;
|
||||
const gremlinClient = new GremlinClient();
|
||||
gremlinClient.initialize({
|
||||
endpoint: `wss://${GraphTab.getGremlinEndpoint(account)}`,
|
||||
databaseId: databaseId,
|
||||
collectionId: collection.id(),
|
||||
masterKey: CosmosClient.masterKey() || "",
|
||||
masterKey: userContext.masterKey || "",
|
||||
maxResultSize: 100
|
||||
});
|
||||
|
||||
|
|
|
@ -35,9 +35,8 @@ import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer
|
|||
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
||||
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
||||
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||
import { DialogComponentAdapter } from "./Controls/DialogReactComponent/DialogComponentAdapter";
|
||||
|
@ -85,6 +84,7 @@ import { NotificationsClientBase } from "../Common/NotificationsClientBase";
|
|||
import { ContextualPaneBase } from "./Panes/ContextualPaneBase";
|
||||
import TabsBase from "./Tabs/TabsBase";
|
||||
import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent";
|
||||
import { updateUserContext, userContext } from "../UserContext";
|
||||
|
||||
BindingHandlersRegisterer.registerBindingHandlers();
|
||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||
|
@ -1603,7 +1603,7 @@ export default class Explorer {
|
|||
|
||||
private async _getArcadiaWorkspaces(): Promise<ArcadiaWorkspaceItem[]> {
|
||||
try {
|
||||
const workspaces = await this._arcadiaManager.listWorkspacesAsync([CosmosClient.subscriptionId()]);
|
||||
const workspaces = await this._arcadiaManager.listWorkspacesAsync([userContext.subscriptionId]);
|
||||
let workspaceItems: ArcadiaWorkspaceItem[] = new Array(workspaces.length);
|
||||
const sparkPromises: Promise<void>[] = [];
|
||||
workspaces.forEach((workspace, i) => {
|
||||
|
@ -1706,7 +1706,7 @@ export default class Explorer {
|
|||
}
|
||||
|
||||
try {
|
||||
const workspaces = await this.notebookWorkspaceManager.getNotebookWorkspacesAsync(databaseAccount.id);
|
||||
const workspaces = await this.notebookWorkspaceManager.getNotebookWorkspacesAsync(databaseAccount?.id);
|
||||
return workspaces && workspaces.length > 0 && workspaces.some(workspace => workspace.name === "default");
|
||||
} catch (error) {
|
||||
Logger.logError(error, "Explorer/_containsDefaultNotebookWorkspace");
|
||||
|
@ -1808,8 +1808,8 @@ export default class Explorer {
|
|||
|
||||
const isRunningInPortal = window.dataExplorerPlatform == PlatformType.Portal;
|
||||
const isRunningInDevMode = process.env.NODE_ENV === "development";
|
||||
if (inputs && config.BACKEND_ENDPOINT && isRunningInPortal && isRunningInDevMode) {
|
||||
inputs.extensionEndpoint = config.PROXY_PATH;
|
||||
if (inputs && configContext.BACKEND_ENDPOINT && isRunningInPortal && isRunningInDevMode) {
|
||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||
}
|
||||
|
||||
const initPromise: Q.Promise<void> = inputs ? this.initDataExplorerWithFrameInputs(inputs) : Q();
|
||||
|
@ -1914,7 +1914,7 @@ export default class Explorer {
|
|||
this.features(inputs.features);
|
||||
this.serverId(inputs.serverId);
|
||||
this.extensionEndpoint(inputs.extensionEndpoint || "");
|
||||
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || config.ARM_ENDPOINT));
|
||||
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
|
||||
this.notificationsClient.setExtensionEndpoint(this.extensionEndpoint());
|
||||
this.databaseAccount(databaseAccount);
|
||||
this.subscriptionType(inputs.subscriptionType);
|
||||
|
@ -1930,11 +1930,12 @@ export default class Explorer {
|
|||
|
||||
this._importExplorerConfigComplete = true;
|
||||
|
||||
CosmosClient.authorizationToken(authorizationToken);
|
||||
CosmosClient.masterKey(masterKey);
|
||||
CosmosClient.databaseAccount(databaseAccount);
|
||||
CosmosClient.subscriptionId(inputs.subscriptionId);
|
||||
CosmosClient.resourceGroup(inputs.resourceGroup);
|
||||
updateUserContext({
|
||||
authorizationToken,
|
||||
masterKey,
|
||||
databaseAccount
|
||||
});
|
||||
updateUserContext({ resourceGroup: inputs.resourceGroup, subscriptionId: inputs.subscriptionId });
|
||||
TelemetryProcessor.traceSuccess(
|
||||
Action.LoadDatabaseAccount,
|
||||
{
|
||||
|
@ -2179,7 +2180,7 @@ export default class Explorer {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const urlPrefixWithKeyParam: string = `${config.hostedExplorerURL}?key=`;
|
||||
const urlPrefixWithKeyParam: string = `${configContext.hostedExplorerURL}?key=`;
|
||||
const currentActiveTab = this.tabsManager.activeTab();
|
||||
|
||||
return `${urlPrefixWithKeyParam}${token}#/${(currentActiveTab && currentActiveTab.hashLocation()) || ""}`;
|
||||
|
@ -2455,14 +2456,14 @@ export default class Explorer {
|
|||
this.tabsManager.activateTab(notebookTab);
|
||||
} else {
|
||||
const options: NotebookTabOptions = {
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.NotebookV2,
|
||||
node: null,
|
||||
title: notebookContentItem.name,
|
||||
tabPath: notebookContentItem.path,
|
||||
collection: null,
|
||||
selfLink: null,
|
||||
masterKey: CosmosClient.masterKey() || "",
|
||||
masterKey: userContext.masterKey || "",
|
||||
hashLocation: "notebooks",
|
||||
isActive: ko.observable(false),
|
||||
isTabsContentExpanded: ko.observable(true),
|
||||
|
@ -2652,7 +2653,7 @@ export default class Explorer {
|
|||
}
|
||||
|
||||
public _refreshSparkEnabledStateForAccount = async (): Promise<void> => {
|
||||
const subscriptionId = CosmosClient.subscriptionId();
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const armEndpoint = this.armEndpoint();
|
||||
const authType = window.authType as AuthType;
|
||||
if (!subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
||||
|
@ -2681,7 +2682,7 @@ export default class Explorer {
|
|||
};
|
||||
|
||||
public _isAfecFeatureRegistered = async (featureName: string): Promise<boolean> => {
|
||||
const subscriptionId = CosmosClient.subscriptionId();
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const armEndpoint = this.armEndpoint();
|
||||
const authType = window.authType as AuthType;
|
||||
if (!featureName || !subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
||||
|
@ -2900,7 +2901,7 @@ export default class Explorer {
|
|||
this.tabsManager.activateTab(terminalTab);
|
||||
} else {
|
||||
const newTab = new TerminalTab({
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.Terminal,
|
||||
node: null,
|
||||
title: title,
|
||||
|
@ -2939,7 +2940,7 @@ export default class Explorer {
|
|||
|
||||
const newTab = new this.galleryTab.default({
|
||||
// GalleryTabOptions
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
container: this,
|
||||
junoClient: this.notebookManager?.junoClient,
|
||||
notebookUrl,
|
||||
|
@ -2986,7 +2987,7 @@ export default class Explorer {
|
|||
this.tabsManager.activateNewTab(notebookViewerTab);
|
||||
} else {
|
||||
notebookViewerTab = new this.notebookViewerTab.default({
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.NotebookViewer,
|
||||
node: null,
|
||||
title: title,
|
||||
|
|
|
@ -24,7 +24,7 @@ import NewNotebookIcon from "../../../../images/notebook/Notebook-new.svg";
|
|||
import ResetWorkspaceIcon from "../../../../images/notebook/Notebook-reset-workspace.svg";
|
||||
import GitHubIcon from "../../../../images/github.svg";
|
||||
import SynapseIcon from "../../../../images/synapse-link.svg";
|
||||
import { config, Platform } from "../../../Config";
|
||||
import { configContext, Platform } from "../../../ConfigContext";
|
||||
import Explorer from "../../Explorer";
|
||||
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||
|
||||
|
@ -243,7 +243,7 @@ export class CommandBarComponentButtonFactory {
|
|||
}
|
||||
|
||||
private static createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonComponentProps {
|
||||
if (config.platform === Platform.Emulator) {
|
||||
if (configContext.platform === Platform.Emulator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ export class CommandBarComponentButtonFactory {
|
|||
}
|
||||
|
||||
private static createEnableNotebooksButton(container: Explorer): CommandButtonComponentProps {
|
||||
if (config.platform === Platform.Emulator) {
|
||||
if (configContext.platform === Platform.Emulator) {
|
||||
return null;
|
||||
}
|
||||
const label = "Enable Notebooks (Preview)";
|
||||
|
|
|
@ -13,14 +13,14 @@ import EnvironmentUtility from "../../Common/EnvironmentUtility";
|
|||
import Q from "q";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { config, Platform } from "../../Config";
|
||||
import { configContext, Platform } from "../../ConfigContext";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { createMongoCollectionWithARM, createMongoCollectionWithProxy } from "../../Common/MongoProxyClient";
|
||||
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
|
||||
import { HashMap } from "../../Common/HashMap";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { refreshCachedResources, getOrCreateDatabaseAndCollection } from "../../Common/DocumentClientUtilityBase";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export interface AddCollectionPaneOptions extends ViewModels.PaneOptions {
|
||||
isPreferredApiTable: ko.Computed<boolean>;
|
||||
|
@ -599,7 +599,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
});
|
||||
|
||||
this.isSynapseLinkSupported = ko.computed(() => {
|
||||
if (config.platform === Platform.Emulator) {
|
||||
if (configContext.platform === Platform.Emulator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -920,9 +920,9 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
partitionKey.version,
|
||||
databaseCreateNew,
|
||||
useDatabaseSharedOffer,
|
||||
CosmosClient.subscriptionId(),
|
||||
CosmosClient.resourceGroup(),
|
||||
CosmosClient.databaseAccount().name,
|
||||
userContext.subscriptionId,
|
||||
userContext.resourceGroup,
|
||||
userContext.databaseAccount.name,
|
||||
autopilotSettings
|
||||
)
|
||||
);
|
||||
|
@ -940,9 +940,9 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||
partitionKey.version,
|
||||
databaseCreateNew,
|
||||
useDatabaseSharedOffer,
|
||||
CosmosClient.subscriptionId(),
|
||||
CosmosClient.resourceGroup(),
|
||||
CosmosClient.databaseAccount().name,
|
||||
userContext.subscriptionId,
|
||||
userContext.resourceGroup,
|
||||
userContext.databaseAccount.name,
|
||||
uniqueKeyPolicy,
|
||||
autopilotSettings
|
||||
)
|
||||
|
|
|
@ -14,9 +14,9 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
|
|||
import { AddDbUtilities } from "../../Shared/AddDatabaseUtility";
|
||||
import { CassandraAPIDataClient } from "../Tables/TableDataClient";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { refreshCachedOffers, refreshCachedResources, createDatabase } from "../../Common/DocumentClientUtilityBase";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class AddDatabasePane extends ContextualPaneBase {
|
||||
public defaultExperience: ko.Computed<string>;
|
||||
|
@ -308,8 +308,8 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||
db: addDatabasePaneStartMessage.database.id,
|
||||
st: addDatabasePaneStartMessage.database.shared,
|
||||
offerThroughput: addDatabasePaneStartMessage.offerThroughput,
|
||||
sid: CosmosClient.subscriptionId(),
|
||||
rg: CosmosClient.resourceGroup(),
|
||||
sid: userContext.subscriptionId,
|
||||
rg: userContext.resourceGroup,
|
||||
dba: addDatabasePaneStartMessage.databaseAccountName
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { ContextualPaneBase } from "./ContextualPaneBase";
|
|||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { StringUtility } from "../../Shared/StringUtility";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
export class SettingsPane extends ContextualPaneBase {
|
||||
public pageOption: ko.Observable<string>;
|
||||
|
@ -46,7 +46,7 @@ export class SettingsPane extends ContextualPaneBase {
|
|||
: false;
|
||||
this.graphAutoVizDisabled = ko.observable<string>(`${isGraphAutoVizDisabled}`);
|
||||
|
||||
this.explorerVersion = config.gitSha;
|
||||
this.explorerVersion = configContext.gitSha;
|
||||
this.shouldShowQueryPageOptions = ko.computed<boolean>(() => this.container.isPreferredApiDocumentDB());
|
||||
this.shouldShowCrossPartitionOption = ko.computed<boolean>(() => !this.container.isPreferredApiGraph());
|
||||
this.shouldShowParallelismOption = ko.computed<boolean>(() => !this.container.isPreferredApiGraph());
|
||||
|
|
|
@ -5,8 +5,6 @@ import * as ko from "knockout";
|
|||
import * as React from "react";
|
||||
import { ReactAdapter } from "../../Bindings/ReactBindingHandler";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
|
||||
import NewContainerIcon from "../../../images/Hero-new-container.svg";
|
||||
import NewNotebookIcon from "../../../images/Hero-new-notebook.svg";
|
||||
import NewQueryIcon from "../../../images/AddSqlQuery_16x16.svg";
|
||||
|
@ -19,6 +17,7 @@ import AddDatabaseIcon from "../../../images/AddDatabase.svg";
|
|||
import SampleIcon from "../../../images/Hero-sample.svg";
|
||||
import { DataSamplesUtil } from "../DataSamples/DataSamplesUtil";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
/**
|
||||
* TODO Remove this when fully ported to ReactJS
|
||||
|
@ -46,7 +45,7 @@ export class SplashScreenComponentAdapter implements ReactAdapter {
|
|||
};
|
||||
|
||||
private clearMostRecent = (): void => {
|
||||
this.container.mostRecentActivity.clear(CosmosClient.databaseAccount().id);
|
||||
this.container.mostRecentActivity.clear(userContext.databaseAccount?.id);
|
||||
this.forceRender();
|
||||
};
|
||||
|
||||
|
@ -195,7 +194,7 @@ export class SplashScreenComponentAdapter implements ReactAdapter {
|
|||
}
|
||||
|
||||
private createRecentItems(): SplashScreenItem[] {
|
||||
return this.container.mostRecentActivity.getItems(CosmosClient.databaseAccount().id).map(item => ({
|
||||
return this.container.mostRecentActivity.getItems(userContext.databaseAccount?.id).map(item => ({
|
||||
iconSrc: MostRecentActivity.MostRecentActivity.getItemIcon(item),
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import * as AddCollectionUtility from "../../Shared/AddCollectionUtility";
|
||||
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
|
@ -14,12 +13,12 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
|||
import TabsBase from "./TabsBase";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateOfferThroughputBeyondLimit, updateOffer } from "../../Common/DocumentClientUtilityBase";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
const updateThroughputBeyondLimitWarningMessage: string = `
|
||||
You are about to request an increase in throughput beyond the pre-allocated capacity.
|
||||
|
@ -521,9 +520,9 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||
this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million
|
||||
) {
|
||||
const requestPayload: DataModels.UpdateOfferThroughputRequest = {
|
||||
subscriptionId: CosmosClient.subscriptionId(),
|
||||
databaseAccountName: CosmosClient.databaseAccount().name,
|
||||
resourceGroup: CosmosClient.resourceGroup(),
|
||||
subscriptionId: userContext.subscriptionId,
|
||||
databaseAccountName: userContext.databaseAccount.name,
|
||||
resourceGroup: userContext.resourceGroup,
|
||||
databaseName: this.database.id(),
|
||||
collectionName: undefined,
|
||||
throughput: newThroughput,
|
||||
|
|
|
@ -9,11 +9,11 @@ import TabsBase from "./TabsBase";
|
|||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { HashMap } from "../../Common/HashMap";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class MongoShellTab extends TabsBase {
|
||||
public url: ko.Computed<string>;
|
||||
|
@ -26,8 +26,8 @@ export default class MongoShellTab extends TabsBase {
|
|||
this._logTraces = new HashMap<number>();
|
||||
this._container = options.collection.container;
|
||||
this.url = ko.computed<string>(() => {
|
||||
const account = CosmosClient.databaseAccount();
|
||||
const resourceId: string = account && account.id;
|
||||
const account = userContext.databaseAccount;
|
||||
const resourceId = account && account.id;
|
||||
const accountName = account && account.name;
|
||||
const mongoEndpoint = account && (account.properties.mongoEndpoint || account.properties.documentEndpoint);
|
||||
|
||||
|
@ -95,7 +95,7 @@ export default class MongoShellTab extends TabsBase {
|
|||
return;
|
||||
}
|
||||
|
||||
const authorization: string = CosmosClient.authorizationToken() || "";
|
||||
const authorization: string = userContext.authorizationToken || "";
|
||||
const resourceId = this._container.databaseAccount().id;
|
||||
const accountName = this._container.databaseAccount().name;
|
||||
const documentEndpoint =
|
||||
|
@ -111,10 +111,10 @@ export default class MongoShellTab extends TabsBase {
|
|||
const collectionId = this.collection.id();
|
||||
const apiEndpoint = EnvironmentUtility.getMongoBackendEndpoint(
|
||||
this._container.serverId(),
|
||||
CosmosClient.databaseAccount().location,
|
||||
userContext.databaseAccount.location,
|
||||
this._container.extensionEndpoint()
|
||||
).replace("/api/mongo/explorer", "");
|
||||
const encryptedAuthToken: string = CosmosClient.accessToken();
|
||||
const encryptedAuthToken: string = userContext.accessToken;
|
||||
|
||||
shellIframe.contentWindow.postMessage(
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"
|
|||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||
import { NotebookConfigurationUtils } from "../../Utils/NotebookConfigurationUtils";
|
||||
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import Explorer from "../Explorer";
|
||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
|
@ -423,7 +423,7 @@ export default class NotebookTabV2 extends TabsBase {
|
|||
password: undefined,
|
||||
endpoints: [
|
||||
{
|
||||
endpoint: `https://${workspace.name}.${config.ARCADIA_LIVY_ENDPOINT_DNS_ZONE}/livyApi/versions/${ArmApiVersions.arcadiaLivy}/sparkPools/${selectedPool.name}/`,
|
||||
endpoint: `https://${workspace.name}.${configContext.ARCADIA_LIVY_ENDPOINT_DNS_ZONE}/livyApi/versions/${ArmApiVersions.arcadiaLivy}/sparkPools/${selectedPool.name}/`,
|
||||
kind: DataModels.SparkClusterEndpointKind.Livy
|
||||
}
|
||||
]
|
||||
|
|
|
@ -14,7 +14,6 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
|||
import TabsBase from "./TabsBase";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||
import Explorer from "../Explorer";
|
||||
|
@ -24,6 +23,7 @@ import {
|
|||
updateCollection
|
||||
} from "../../Common/DocumentClientUtilityBase";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
const ttlWarning: string = `
|
||||
The system will automatically delete items based on the TTL value (in seconds) you provide, without needing a delete operation explicitly issued by a client application.
|
||||
|
@ -1145,9 +1145,9 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
|||
this.container != null
|
||||
) {
|
||||
const requestPayload: DataModels.UpdateOfferThroughputRequest = {
|
||||
subscriptionId: CosmosClient.subscriptionId(),
|
||||
databaseAccountName: CosmosClient.databaseAccount().name,
|
||||
resourceGroup: CosmosClient.resourceGroup(),
|
||||
subscriptionId: userContext.subscriptionId,
|
||||
databaseAccountName: userContext.databaseAccount.name,
|
||||
resourceGroup: userContext.resourceGroup,
|
||||
databaseName: this.collection.databaseId,
|
||||
collectionName: this.collection.id(),
|
||||
throughput: newThroughput,
|
||||
|
|
|
@ -4,7 +4,6 @@ import * as _ from "underscore";
|
|||
import UploadWorker from "worker-loader!../../workers/upload";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
|
@ -31,7 +30,7 @@ import SettingsTab from "../Tabs/SettingsTab";
|
|||
import StoredProcedure from "./StoredProcedure";
|
||||
import Trigger from "./Trigger";
|
||||
import UserDefinedFunction from "./UserDefinedFunction";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import Explorer from "../Explorer";
|
||||
import {
|
||||
createDocument,
|
||||
|
@ -42,6 +41,7 @@ import {
|
|||
readOffer,
|
||||
readOffers
|
||||
} from "../../Common/DocumentClientUtilityBase";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class Collection implements ViewModels.Collection {
|
||||
public nodeKind: string;
|
||||
|
@ -472,7 +472,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
});
|
||||
|
||||
graphTab = new GraphTab({
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.Graph,
|
||||
node: this,
|
||||
title: title,
|
||||
|
@ -480,7 +480,7 @@ export default class Collection implements ViewModels.Collection {
|
|||
|
||||
collection: this,
|
||||
selfLink: this.self,
|
||||
masterKey: CosmosClient.masterKey() || "",
|
||||
masterKey: userContext.masterKey || "",
|
||||
collectionPartitionKeyProperty: this.partitionKeyProperty,
|
||||
hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/graphs`,
|
||||
collectionId: this.id(),
|
||||
|
@ -804,14 +804,14 @@ export default class Collection implements ViewModels.Collection {
|
|||
});
|
||||
|
||||
const graphTab: GraphTab = new GraphTab({
|
||||
account: CosmosClient.databaseAccount(),
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.Graph,
|
||||
node: this,
|
||||
title: title,
|
||||
tabPath: "",
|
||||
collection: this,
|
||||
selfLink: this.self,
|
||||
masterKey: CosmosClient.masterKey() || "",
|
||||
masterKey: userContext.masterKey || "",
|
||||
collectionPartitionKeyProperty: this.partitionKeyProperty,
|
||||
hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/graphs`,
|
||||
collectionId: this.id(),
|
||||
|
@ -1181,11 +1181,11 @@ export default class Collection implements ViewModels.Collection {
|
|||
documentClientParams: {
|
||||
databaseId: this.databaseId,
|
||||
containerId: this.id(),
|
||||
masterKey: CosmosClient.masterKey(),
|
||||
endpoint: CosmosClient.endpoint(),
|
||||
accessToken: CosmosClient.accessToken(),
|
||||
platform: config.platform,
|
||||
databaseAccount: CosmosClient.databaseAccount()
|
||||
masterKey: userContext.masterKey,
|
||||
endpoint: userContext.endpoint,
|
||||
accessToken: userContext.accessToken,
|
||||
platform: configContext.platform,
|
||||
databaseAccount: userContext.databaseAccount
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import * as ViewModels from "../../Contracts/ViewModels";
|
|||
import { NotebookContentItem, NotebookContentItemType } from "../Notebook/NotebookContentItem";
|
||||
import { ResourceTreeContextMenuButtonFactory } from "../ContextMenuButtonFactory";
|
||||
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import CosmosDBIcon from "../../../images/Azure-Cosmos-DB.svg";
|
||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||
import DeleteIcon from "../../../images/delete.svg";
|
||||
|
@ -31,6 +30,7 @@ import UserDefinedFunction from "./UserDefinedFunction";
|
|||
import StoredProcedure from "./StoredProcedure";
|
||||
import Trigger from "./Trigger";
|
||||
import TabsBase from "../Tabs/TabsBase";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export class ResourceTreeAdapter implements ReactAdapter {
|
||||
private static readonly DataTitle = "DATA";
|
||||
|
@ -224,7 +224,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||
onClick: () => {
|
||||
collection.openTab();
|
||||
// push to most recent
|
||||
this.container.mostRecentActivity.addItem(CosmosClient.databaseAccount().id, {
|
||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||
type: MostRecentActivity.Type.OpenCollection,
|
||||
title: collection.id(),
|
||||
description: "Data",
|
||||
|
@ -490,7 +490,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||
}
|
||||
|
||||
private pushItemToMostRecent(item: NotebookContentItem) {
|
||||
this.container.mostRecentActivity.addItem(CosmosClient.databaseAccount().id, {
|
||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||
type: MostRecentActivity.Type.OpenNotebook,
|
||||
title: item.name,
|
||||
description: "Notebook",
|
||||
|
|
|
@ -2,12 +2,12 @@ import * as ko from "knockout";
|
|||
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
|
||||
import * as React from "react";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
||||
import { ReactAdapter } from "../../Bindings/ReactBindingHandler";
|
||||
import { TreeComponent, TreeNode } from "../Controls/TreeComponent/TreeComponent";
|
||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
||||
public parameters: ko.Observable<number>;
|
||||
|
@ -44,7 +44,7 @@ export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
|||
onClick: () => {
|
||||
collection.onDocumentDBDocumentsClick();
|
||||
// push to most recent
|
||||
this.container.mostRecentActivity.addItem(CosmosClient.databaseAccount().id, {
|
||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||
type: MostRecentActivity.Type.OpenCollection,
|
||||
title: collection.id(),
|
||||
description: "Data",
|
||||
|
|
|
@ -3,7 +3,7 @@ import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
|||
import { Text, Link } from "office-ui-fabric-react";
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import { initializeConfiguration } from "../Config";
|
||||
import { initializeConfiguration } from "../ConfigContext";
|
||||
import { GalleryHeaderComponent } from "../Explorer/Controls/Header/GalleryHeaderComponent";
|
||||
import {
|
||||
GalleryAndNotebookViewerComponent,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import ko from "knockout";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeAccessComponent";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { JunoClient } from "../Juno/JunoClient";
|
||||
|
@ -55,7 +55,7 @@ export class GitHubOAuthService {
|
|||
|
||||
const params = {
|
||||
scope,
|
||||
client_id: config.GITHUB_CLIENT_ID,
|
||||
client_id: configContext.GITHUB_CLIENT_ID,
|
||||
redirect_uri: new URL("./connectToGitHub.html", window.location.href).href,
|
||||
state: this.resetState()
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import ko from "knockout";
|
|||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { IPinnedRepo, JunoClient, IGalleryItem } from "./JunoClient";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { DatabaseAccount } from "../Contracts/DataModels";
|
||||
|
||||
|
@ -163,7 +163,7 @@ describe("Gallery", () => {
|
|||
const response = await junoClient.getSampleNotebooks();
|
||||
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/samples`, undefined);
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/samples`, undefined);
|
||||
});
|
||||
|
||||
it("getPublicNotebooks", async () => {
|
||||
|
@ -175,7 +175,7 @@ describe("Gallery", () => {
|
|||
const response = await junoClient.getPublicNotebooks();
|
||||
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/public`, undefined);
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/public`, undefined);
|
||||
});
|
||||
|
||||
it("getNotebook", async () => {
|
||||
|
@ -188,7 +188,7 @@ describe("Gallery", () => {
|
|||
const response = await junoClient.getNotebook(id);
|
||||
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/${id}`);
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/${id}`);
|
||||
});
|
||||
|
||||
it("getNotebookContent", async () => {
|
||||
|
@ -201,7 +201,7 @@ describe("Gallery", () => {
|
|||
const response = await junoClient.getNotebookContent(id);
|
||||
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/content`);
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/content`);
|
||||
});
|
||||
|
||||
it("increaseNotebookViews", async () => {
|
||||
|
@ -214,7 +214,7 @@ describe("Gallery", () => {
|
|||
const response = await junoClient.increaseNotebookViews(id);
|
||||
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/views`, {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/views`, {
|
||||
method: "PATCH"
|
||||
});
|
||||
});
|
||||
|
@ -231,7 +231,7 @@ describe("Gallery", () => {
|
|||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(
|
||||
`${config.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery/${id}/downloads`,
|
||||
`${configContext.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery/${id}/downloads`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
|
@ -254,7 +254,7 @@ describe("Gallery", () => {
|
|||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(
|
||||
`${config.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery/${id}/favorite`,
|
||||
`${configContext.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery/${id}/favorite`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
|
@ -276,7 +276,7 @@ describe("Gallery", () => {
|
|||
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/unfavorite`, {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/${id}/unfavorite`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
|
@ -295,7 +295,7 @@ describe("Gallery", () => {
|
|||
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/favorites`, {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/favorites`, {
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
|
@ -313,7 +313,7 @@ describe("Gallery", () => {
|
|||
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/published`, {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/published`, {
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
|
@ -332,7 +332,7 @@ describe("Gallery", () => {
|
|||
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/gallery/${id}`, {
|
||||
expect(window.fetch).toBeCalledWith(`${configContext.JUNO_ENDPOINT}/api/notebooks/gallery/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
|
@ -357,20 +357,23 @@ describe("Gallery", () => {
|
|||
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
expect(response.status).toBe(HttpStatusCodes.OK);
|
||||
expect(window.fetch).toBeCalledWith(`${config.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
description,
|
||||
tags,
|
||||
author,
|
||||
thumbnailUrl,
|
||||
content: JSON.parse(content)
|
||||
})
|
||||
});
|
||||
expect(window.fetch).toBeCalledWith(
|
||||
`${configContext.JUNO_ENDPOINT}/api/notebooks/${sampleDatabaseAccount.name}/gallery`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
[authorizationHeader.header]: authorizationHeader.token,
|
||||
"content-type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
description,
|
||||
tags,
|
||||
author,
|
||||
thumbnailUrl,
|
||||
content: JSON.parse(content)
|
||||
})
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ko from "knockout";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeAccessComponent";
|
||||
import { IGitHubResponse } from "../GitHub/GitHubClient";
|
||||
|
@ -341,11 +341,11 @@ export class JunoClient {
|
|||
}
|
||||
|
||||
private getNotebooksUrl(): string {
|
||||
return `${config.JUNO_ENDPOINT}/api/notebooks`;
|
||||
return `${configContext.JUNO_ENDPOINT}/api/notebooks`;
|
||||
}
|
||||
|
||||
private getNotebooksAccountUrl(): string {
|
||||
return `${config.JUNO_ENDPOINT}/api/notebooks/${this.databaseAccount().name}`;
|
||||
return `${configContext.JUNO_ENDPOINT}/api/notebooks/${this.databaseAccount().name}`;
|
||||
}
|
||||
|
||||
private static getHeaders(): HeadersInit {
|
||||
|
@ -358,11 +358,11 @@ export class JunoClient {
|
|||
|
||||
private static getGitHubClientParams(): URLSearchParams {
|
||||
const githubParams = new URLSearchParams({
|
||||
client_id: config.GITHUB_CLIENT_ID
|
||||
client_id: configContext.GITHUB_CLIENT_ID
|
||||
});
|
||||
|
||||
if (config.GITHUB_CLIENT_SECRET) {
|
||||
githubParams.append("client_secret", config.GITHUB_CLIENT_SECRET);
|
||||
if (configContext.GITHUB_CLIENT_SECRET) {
|
||||
githubParams.append("client_secret", configContext.GITHUB_CLIENT_SECRET);
|
||||
}
|
||||
|
||||
return githubParams;
|
||||
|
|
|
@ -73,7 +73,7 @@ import { AuthType } from "./AuthType";
|
|||
|
||||
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
||||
import { applyExplorerBindings } from "./applyExplorerBindings";
|
||||
import { initializeConfiguration, Platform } from "./Config";
|
||||
import { initializeConfiguration, Platform } from "./ConfigContext";
|
||||
import Explorer from "./Explorer/Explorer";
|
||||
|
||||
initializeIcons(/* optional base url */);
|
||||
|
|
|
@ -2,7 +2,7 @@ import "bootstrap/dist/css/bootstrap.css";
|
|||
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
||||
import React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import { initializeConfiguration } from "../Config";
|
||||
import { initializeConfiguration } from "../ConfigContext";
|
||||
import {
|
||||
NotebookViewerComponent,
|
||||
NotebookViewerComponentProps
|
||||
|
|
|
@ -2,13 +2,13 @@ import AuthHeadersUtil from "./Authorization";
|
|||
import * as Constants from "../../Common/Constants";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { Tenant, Subscription, DatabaseAccount, AccountKeys } from "../../Contracts/DataModels";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
// TODO: 421864 - add a fetch wrapper
|
||||
export abstract class ArmResourceUtils {
|
||||
private static readonly _armEndpoint: string = config.ARM_ENDPOINT;
|
||||
private static readonly _armApiVersion: string = config.ARM_API_VERSION;
|
||||
private static readonly _armAuthArea: string = config.ARM_AUTH_AREA;
|
||||
private static readonly _armEndpoint: string = configContext.ARM_ENDPOINT;
|
||||
private static readonly _armApiVersion: string = configContext.ARM_API_VERSION;
|
||||
private static readonly _armAuthArea: string = configContext.ARM_AUTH_AREA;
|
||||
|
||||
// TODO: 422867 - return continuation token instead of read through
|
||||
public static async listTenants(): Promise<Array<Tenant>> {
|
||||
|
|
|
@ -3,14 +3,13 @@ import "expose-loader?AuthenticationContext!../../../externals/adal";
|
|||
import Q from "q";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { AuthType } from "../../AuthType";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class AuthHeadersUtil {
|
||||
// TODO: Figure out a way to determine the extension endpoint and serverId at runtime
|
||||
|
@ -18,12 +17,12 @@ export default class AuthHeadersUtil {
|
|||
public static serverId: string = Constants.ServerIds.productionPortal;
|
||||
|
||||
private static readonly _firstPartyAppId: string = "203f1145-856a-4232-83d4-a43568fba23d";
|
||||
private static readonly _aadEndpoint: string = config.AAD_ENDPOINT;
|
||||
private static readonly _armEndpoint: string = config.ARM_ENDPOINT;
|
||||
private static readonly _arcadiaEndpoint: string = config.ARCADIA_ENDPOINT;
|
||||
private static readonly _armAuthArea: string = config.ARM_AUTH_AREA;
|
||||
private static readonly _graphEndpoint: string = config.GRAPH_ENDPOINT;
|
||||
private static readonly _graphApiVersion: string = config.GRAPH_API_VERSION;
|
||||
private static readonly _aadEndpoint: string = configContext.AAD_ENDPOINT;
|
||||
private static readonly _armEndpoint: string = configContext.ARM_ENDPOINT;
|
||||
private static readonly _arcadiaEndpoint: string = configContext.ARCADIA_ENDPOINT;
|
||||
private static readonly _armAuthArea: string = configContext.ARM_AUTH_AREA;
|
||||
private static readonly _graphEndpoint: string = configContext.GRAPH_ENDPOINT;
|
||||
private static readonly _graphApiVersion: string = configContext.GRAPH_API_VERSION;
|
||||
|
||||
private static _authContext: AuthenticationContext = new AuthenticationContext({
|
||||
instance: AuthHeadersUtil._aadEndpoint,
|
||||
|
@ -91,7 +90,7 @@ export default class AuthHeadersUtil {
|
|||
AuthHeadersUtil.extensionEndpoint
|
||||
}/api/tokens/generateToken${AuthHeadersUtil._generateResourceUrl()}`;
|
||||
const explorer = window.dataExplorer;
|
||||
const headers: any = { authorization: CosmosClient.authorizationToken() };
|
||||
const headers: any = { authorization: userContext.authorizationToken };
|
||||
headers[Constants.HttpHeaders.getReadOnlyKey] = !explorer.hasWriteAccess();
|
||||
|
||||
return AuthHeadersUtil._initiateGenerateTokenRequest({
|
||||
|
@ -272,9 +271,9 @@ export default class AuthHeadersUtil {
|
|||
}
|
||||
|
||||
private static _generateResourceUrl(): string {
|
||||
const databaseAccount = CosmosClient.databaseAccount();
|
||||
const subscriptionId: string = CosmosClient.subscriptionId();
|
||||
const resourceGroup: string = CosmosClient.resourceGroup();
|
||||
const databaseAccount = userContext.databaseAccount;
|
||||
const subscriptionId: string = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
const defaultExperience: string = DefaultExperienceUtility.getDefaultExperienceFromDatabaseAccount(databaseAccount);
|
||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
||||
const accountEndpoint = (databaseAccount && databaseAccount.properties.documentEndpoint) || "";
|
||||
|
|
|
@ -14,7 +14,6 @@ import {
|
|||
import { AuthType } from "../../AuthType";
|
||||
import { CollectionCreation } from "../../Shared/Constants";
|
||||
import { isInvalidParentFrameOrigin } from "../../Utils/MessageValidation";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { DataExplorerInputsFrame } from "../../Contracts/ViewModels";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import { HostedUtils } from "./HostedUtils";
|
||||
|
@ -24,6 +23,7 @@ import { SessionStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
|||
import { SubscriptionUtilMappings } from "../../Shared/Constants";
|
||||
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
export default class Main {
|
||||
private static _databaseAccountId: string;
|
||||
|
@ -84,7 +84,9 @@ export default class Main {
|
|||
displayText: "Loading..."
|
||||
}
|
||||
});
|
||||
CosmosClient.accessToken(Main._encryptedToken);
|
||||
updateUserContext({
|
||||
accessToken: Main._encryptedToken
|
||||
});
|
||||
Main._getAccessInputMetadata(Main._encryptedToken).then(
|
||||
() => {
|
||||
const expiryTimestamp: number =
|
||||
|
@ -203,7 +205,9 @@ export default class Main {
|
|||
Main._encryptedToken = encryptedToken.readWrite;
|
||||
window.authType = AuthType.EncryptedToken;
|
||||
|
||||
CosmosClient.accessToken(Main._encryptedToken);
|
||||
updateUserContext({
|
||||
accessToken: Main._encryptedToken
|
||||
});
|
||||
Main._getAccessInputMetadata(Main._encryptedToken).then(
|
||||
() => {
|
||||
if (explorer.isConnectExplorerVisible()) {
|
||||
|
@ -472,8 +476,10 @@ export default class Main {
|
|||
console.error("Invalid connection string input");
|
||||
Q.reject("Invalid connection string input");
|
||||
}
|
||||
CosmosClient.resourceToken(properties.resourceToken);
|
||||
CosmosClient.endpoint(properties.accountEndpoint);
|
||||
updateUserContext({
|
||||
resourceToken: properties.resourceToken,
|
||||
endpoint: properties.accountEndpoint
|
||||
});
|
||||
explorer.resourceTokenDatabaseId(properties.databaseId);
|
||||
explorer.resourceTokenCollectionId(properties.collectionId);
|
||||
if (properties.partitionKey) {
|
||||
|
|
|
@ -5,13 +5,13 @@ import * as SharedConstants from "./Constants";
|
|||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { sendMessage } from "../Common/MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class CreateSqlCollectionUtilities {
|
||||
public static createSqlCollection(
|
||||
|
@ -298,8 +298,6 @@ export class Utilities {
|
|||
}
|
||||
|
||||
private static _getAzureTableUri(params: DataModels.CreateDatabaseAndCollectionRequest): string {
|
||||
return `subscriptions/${CosmosClient.subscriptionId()}/resourceGroups/${CosmosClient.resourceGroup()}/providers/Microsoft.DocumentDB/databaseAccounts/${
|
||||
CosmosClient.databaseAccount().name
|
||||
}/tables/${params.collectionId}`;
|
||||
return `subscriptions/${userContext.subscriptionId}/resourceGroups/${userContext.resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${userContext.databaseAccount.name}/tables/${params.collectionId}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as DataExplorerConstants from "../Common/Constants";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { sendMessage } from "../Common/MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class AddDbUtilities {
|
||||
// todo - remove any
|
||||
|
@ -115,7 +115,7 @@ export class AddDbUtilities {
|
|||
}
|
||||
|
||||
public static getRpClient<T>(armEndpoint?: string): ResourceProviderClient<T> {
|
||||
return new ResourceProviderClient<T>(armEndpoint || config.ARM_ENDPOINT);
|
||||
return new ResourceProviderClient<T>(armEndpoint || configContext.ARM_ENDPOINT);
|
||||
}
|
||||
|
||||
public static async createGremlinDatabase(
|
||||
|
@ -171,15 +171,11 @@ export class AddDbUtilities {
|
|||
}
|
||||
|
||||
private static _getMongoDatabaseUri(params: DataModels.RpParameters): string {
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${
|
||||
CosmosClient.databaseAccount().name
|
||||
}/mongodbDatabases/${params.db}`;
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${userContext.databaseAccount.name}/mongodbDatabases/${params.db}`;
|
||||
}
|
||||
|
||||
private static _getCassandraKeyspaceUri(params: DataModels.RpParameters): string {
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${
|
||||
CosmosClient.databaseAccount().name
|
||||
}/cassandraKeyspaces/${params.db}`;
|
||||
return `subscriptions/${params.sid}/resourceGroups/${params.rg}/providers/Microsoft.DocumentDB/databaseAccounts/${userContext.databaseAccount.name}/cassandraKeyspaces/${params.db}`;
|
||||
}
|
||||
|
||||
public static getGremlinDatabaseUri(params: DataModels.RpParameters): string {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { sendMessage } from "../../Common/MessageHandler";
|
||||
import { MessageTypes } from "../../Contracts/ExplorerContracts";
|
||||
import { appInsights } from "../appInsights";
|
||||
import { config } from "../../Config";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
/**
|
||||
* Class that persists telemetry data to the portal tables.
|
||||
|
@ -115,7 +115,7 @@ export default class TelemetryProcessor {
|
|||
|
||||
private static getData(data?: any): any {
|
||||
return {
|
||||
platform: config.platform,
|
||||
platform: configContext.platform,
|
||||
...(data ? data : [])
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ import { ArmApiVersions, ArmResourceTypes } from "../Common/Constants";
|
|||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
|
||||
export class ArcadiaResourceManager {
|
||||
private resourceProviderClientFactory: IResourceProviderClientFactory<any>;
|
||||
|
||||
constructor(private armEndpoint = config.ARM_ENDPOINT) {
|
||||
constructor(private armEndpoint = configContext.ARM_ENDPOINT) {
|
||||
this.resourceProviderClientFactory = new ResourceProviderClientFactory(this.armEndpoint);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class PortalTokenProvider implements ViewModels.TokenProvider {
|
||||
constructor() {}
|
||||
|
||||
public async getAuthHeader(): Promise<Headers> {
|
||||
const bearerToken = CosmosClient.authorizationToken();
|
||||
const bearerToken = userContext.authorizationToken;
|
||||
let fetchHeaders = new Headers();
|
||||
fetchHeaders.append("authorization", bearerToken);
|
||||
return fetchHeaders;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import { DatabaseAccount } from "./Contracts/DataModels";
|
||||
|
||||
interface UserContext {
|
||||
masterKey?: string;
|
||||
subscriptionId?: string;
|
||||
resourceGroup?: string;
|
||||
databaseAccount?: DatabaseAccount;
|
||||
endpoint?: string;
|
||||
accessToken?: string;
|
||||
authorizationToken?: string;
|
||||
resourceToken?: string;
|
||||
}
|
||||
|
||||
const userContext: Readonly<UserContext> = {} as const;
|
||||
|
||||
function updateUserContext(newContext: UserContext): void {
|
||||
Object.assign(userContext, newContext);
|
||||
}
|
||||
|
||||
export { userContext, updateUserContext };
|
|
@ -1,30 +1,18 @@
|
|||
import * as ko from "knockout";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as AuthorizationUtils from "./AuthorizationUtils";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { PlatformType } from "../PlatformType";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
jest.mock("../Explorer/Explorer");
|
||||
|
||||
describe("AuthorizationUtils", () => {
|
||||
let originalAuthorizationToken: string;
|
||||
let originalAccessToken: string;
|
||||
|
||||
beforeAll(() => {
|
||||
originalAuthorizationToken = CosmosClient.authorizationToken();
|
||||
originalAccessToken = CosmosClient.accessToken();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
CosmosClient.authorizationToken && CosmosClient.authorizationToken(originalAuthorizationToken);
|
||||
CosmosClient.accessToken(originalAccessToken);
|
||||
});
|
||||
|
||||
describe("getAuthorizationHeader()", () => {
|
||||
it("should return authorization header if authentication type is AAD", () => {
|
||||
window.authType = AuthType.AAD;
|
||||
CosmosClient.authorizationToken = ko.observable("some-token");
|
||||
updateUserContext({
|
||||
authorizationToken: "some-token"
|
||||
});
|
||||
|
||||
expect(AuthorizationUtils.getAuthorizationHeader().header).toBe(Constants.HttpHeaders.authorization);
|
||||
expect(AuthorizationUtils.getAuthorizationHeader().token).toBe("some-token");
|
||||
|
@ -32,7 +20,9 @@ describe("AuthorizationUtils", () => {
|
|||
|
||||
it("should return guest access header if authentication type is EncryptedToken", () => {
|
||||
window.authType = AuthType.EncryptedToken;
|
||||
CosmosClient.accessToken = ko.observable("some-token");
|
||||
updateUserContext({
|
||||
accessToken: "some-token"
|
||||
});
|
||||
|
||||
expect(AuthorizationUtils.getAuthorizationHeader().header).toBe(Constants.HttpHeaders.guestAccessToken);
|
||||
expect(AuthorizationUtils.getAuthorizationHeader().token).toBe("some-token");
|
||||
|
|
|
@ -4,25 +4,25 @@ import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
|||
import { AuthType } from "../AuthType";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { PlatformType } from "../PlatformType";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export function getAuthorizationHeader(): ViewModels.AuthorizationTokenHeaderMetadata {
|
||||
if (window.authType === AuthType.EncryptedToken) {
|
||||
return {
|
||||
header: Constants.HttpHeaders.guestAccessToken,
|
||||
token: CosmosClient.accessToken()
|
||||
token: userContext.accessToken
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
header: Constants.HttpHeaders.authorization,
|
||||
token: CosmosClient.authorizationToken() || ""
|
||||
token: userContext.authorizationToken || ""
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getArcadiaAuthToken(
|
||||
arcadiaEndpoint: string = config.ARCADIA_ENDPOINT,
|
||||
arcadiaEndpoint: string = configContext.ARCADIA_ENDPOINT,
|
||||
tenantId?: string
|
||||
): Promise<string> {
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { config } from "../Config";
|
||||
import { configContext } from "../ConfigContext";
|
||||
|
||||
export function isInvalidParentFrameOrigin(event: MessageEvent): boolean {
|
||||
return !isValidOrigin(config.allowedParentFrameOrigins, event);
|
||||
return !isValidOrigin(configContext.allowedParentFrameOrigins, event);
|
||||
}
|
||||
|
||||
function isValidOrigin(allowedOrigins: RegExp, event: MessageEvent): boolean {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||
import { decryptJWTToken } from "./AuthorizationUtils";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export function getFullName(): string {
|
||||
let fullName: string;
|
||||
|
@ -8,7 +8,7 @@ export function getFullName(): string {
|
|||
if (user) {
|
||||
fullName = user.profile.name;
|
||||
} else {
|
||||
const authToken = CosmosClient.authorizationToken();
|
||||
const authToken = userContext.authorizationToken;
|
||||
const props = decryptJWTToken(authToken);
|
||||
fullName = props.name;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function listCassandraKeyspaces(
|
|||
accountName: string
|
||||
): Promise<Types.CassandraKeyspaceListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -27,7 +27,7 @@ export async function getCassandraKeyspace(
|
|||
keyspaceName: string
|
||||
): Promise<Types.CassandraKeyspaceGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB Cassandra keyspace */
|
||||
|
@ -39,7 +39,7 @@ export async function createUpdateCassandraKeyspace(
|
|||
body: Types.CassandraKeyspaceCreateUpdateParameters
|
||||
): Promise<Types.CassandraKeyspaceGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB Cassandra keyspace. */
|
||||
|
@ -50,7 +50,7 @@ export async function deleteCassandraKeyspace(
|
|||
keyspaceName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -61,7 +61,7 @@ export async function getCassandraKeyspaceThroughput(
|
|||
keyspaceName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB Cassandra Keyspace */
|
||||
|
@ -73,7 +73,7 @@ export async function updateCassandraKeyspaceThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to autoscale */
|
||||
|
@ -84,7 +84,7 @@ export async function migrateCassandraKeyspaceToAutoscale(
|
|||
keyspaceName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual throughput */
|
||||
|
@ -95,7 +95,7 @@ export async function migrateCassandraKeyspaceToManualThroughput(
|
|||
keyspaceName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the Cassandra table under an existing Azure Cosmos DB database account. */
|
||||
|
@ -106,7 +106,7 @@ export async function listCassandraTables(
|
|||
keyspaceName: string
|
||||
): Promise<Types.CassandraTableListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Cassandra table under an existing Azure Cosmos DB database account. */
|
||||
|
@ -118,7 +118,7 @@ export async function getCassandraTable(
|
|||
tableName: string
|
||||
): Promise<Types.CassandraTableGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB Cassandra Table */
|
||||
|
@ -131,7 +131,7 @@ export async function createUpdateCassandraTable(
|
|||
body: Types.CassandraTableCreateUpdateParameters
|
||||
): Promise<Types.CassandraTableGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB Cassandra table. */
|
||||
|
@ -143,7 +143,7 @@ export async function deleteCassandraTable(
|
|||
tableName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -155,7 +155,7 @@ export async function getCassandraTableThroughput(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB Cassandra table */
|
||||
|
@ -168,7 +168,7 @@ export async function updateCassandraTableThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale */
|
||||
|
@ -180,7 +180,7 @@ export async function migrateCassandraTableToAutoscale(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput */
|
||||
|
@ -192,5 +192,5 @@ export async function migrateCassandraTableToManualThroughput(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/cassandraKeyspaces/${keyspaceName}/tables/${tableName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account and collection. */
|
||||
|
@ -18,7 +18,7 @@ export async function listMetrics(
|
|||
collectionRid: string
|
||||
): Promise<Types.MetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves the usages (most recent storage data) for the given collection. */
|
||||
|
@ -30,7 +30,7 @@ export async function listUsages(
|
|||
collectionRid: string
|
||||
): Promise<Types.UsagesResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/usages`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves metric definitions for the given collection. */
|
||||
|
@ -42,5 +42,5 @@ export async function listMetricDefinitions(
|
|||
collectionRid: string
|
||||
): Promise<Types.MetricDefinitionsListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/metricDefinitions`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given collection, split by partition. */
|
||||
|
@ -18,7 +18,7 @@ export async function listMetrics(
|
|||
collectionRid: string
|
||||
): Promise<Types.PartitionMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves the usages (most recent storage data) for the given collection, split by partition. */
|
||||
|
@ -30,5 +30,5 @@ export async function listUsages(
|
|||
collectionRid: string
|
||||
): Promise<Types.PartitionUsagesResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitions/usages`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given collection and region, split by partition. */
|
||||
|
@ -19,5 +19,5 @@ export async function listMetrics(
|
|||
collectionRid: string
|
||||
): Promise<Types.PartitionMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitions/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account, collection and region. */
|
||||
|
@ -19,5 +19,5 @@ export async function listMetrics(
|
|||
collectionRid: string
|
||||
): Promise<Types.MetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account and database. */
|
||||
|
@ -17,7 +17,7 @@ export async function listMetrics(
|
|||
databaseRid: string
|
||||
): Promise<Types.MetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves the usages (most recent data) for the given database. */
|
||||
|
@ -28,7 +28,7 @@ export async function listUsages(
|
|||
databaseRid: string
|
||||
): Promise<Types.UsagesResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/usages`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves metric definitions for the given database. */
|
||||
|
@ -39,5 +39,5 @@ export async function listMetricDefinitions(
|
|||
databaseRid: string
|
||||
): Promise<Types.MetricDefinitionsListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/metricDefinitions`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account and region. */
|
||||
|
@ -17,5 +17,5 @@ export async function listMetrics(
|
|||
region: string
|
||||
): Promise<Types.MetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the properties of an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function get(
|
|||
accountName: string
|
||||
): Promise<Types.DatabaseAccountGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Updates the properties of an existing Azure Cosmos DB database account. */
|
||||
|
@ -27,7 +27,13 @@ export async function update(
|
|||
body: Types.DatabaseAccountUpdateParameters
|
||||
): Promise<Types.DatabaseAccountGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PATCH", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({
|
||||
host: configContext.ARM_ENDPOINT,
|
||||
path,
|
||||
method: "PATCH",
|
||||
apiVersion,
|
||||
body: JSON.stringify(body)
|
||||
});
|
||||
}
|
||||
|
||||
/* Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. */
|
||||
|
@ -38,13 +44,13 @@ export async function createOrUpdate(
|
|||
body: Types.DatabaseAccountCreateUpdateParameters
|
||||
): Promise<Types.DatabaseAccountGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB database account. */
|
||||
export async function destroy(subscriptionId: string, resourceGroupName: string, accountName: string): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. */
|
||||
|
@ -55,13 +61,13 @@ export async function failoverPriorityChange(
|
|||
body: Types.FailoverPolicies
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/failoverPriorityChange`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Lists all the Azure Cosmos DB database accounts available under the subscription. */
|
||||
export async function list(subscriptionId: string): Promise<Types.DatabaseAccountsListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists all the Azure Cosmos DB database accounts available under the given resource group. */
|
||||
|
@ -70,7 +76,7 @@ export async function listByResourceGroup(
|
|||
resourceGroupName: string
|
||||
): Promise<Types.DatabaseAccountsListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the access keys for the specified Azure Cosmos DB database account. */
|
||||
|
@ -80,7 +86,7 @@ export async function listKeys(
|
|||
accountName: string
|
||||
): Promise<Types.DatabaseAccountListKeysResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listKeys`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the connection strings for the specified Azure Cosmos DB database account. */
|
||||
|
@ -90,7 +96,7 @@ export async function listConnectionStrings(
|
|||
accountName: string
|
||||
): Promise<Types.DatabaseAccountListConnectionStringsResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/listConnectionStrings`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Offline the specified region for the specified Azure Cosmos DB database account. */
|
||||
|
@ -101,7 +107,7 @@ export async function offlineRegion(
|
|||
body: Types.RegionForOnlineOffline
|
||||
): Promise<void | Types.ErrorResponse> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/offlineRegion`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Online the specified region for the specified Azure Cosmos DB database account. */
|
||||
|
@ -112,7 +118,7 @@ export async function onlineRegion(
|
|||
body: Types.RegionForOnlineOffline
|
||||
): Promise<void | Types.ErrorResponse> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/onlineRegion`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Lists the read-only access keys for the specified Azure Cosmos DB database account. */
|
||||
|
@ -122,7 +128,7 @@ export async function getReadOnlyKeys(
|
|||
accountName: string
|
||||
): Promise<Types.DatabaseAccountListReadOnlyKeysResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the read-only access keys for the specified Azure Cosmos DB database account. */
|
||||
|
@ -132,7 +138,7 @@ export async function listReadOnlyKeys(
|
|||
accountName: string
|
||||
): Promise<Types.DatabaseAccountListReadOnlyKeysResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/readonlykeys`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Regenerates an access key for the specified Azure Cosmos DB database account. */
|
||||
|
@ -143,13 +149,13 @@ export async function regenerateKey(
|
|||
body: Types.DatabaseAccountRegenerateKeyParameters
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/regenerateKey`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. */
|
||||
export async function checkNameExists(accountName: string): Promise<void> {
|
||||
const path = `/providers/Microsoft.DocumentDB/databaseAccountNames/${accountName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "HEAD", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "HEAD", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account. */
|
||||
|
@ -159,7 +165,7 @@ export async function listMetrics(
|
|||
accountName: string
|
||||
): Promise<Types.MetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves the usages (most recent data) for the given database account. */
|
||||
|
@ -169,7 +175,7 @@ export async function listUsages(
|
|||
accountName: string
|
||||
): Promise<Types.UsagesResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/usages`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Retrieves metric definitions for the given database account. */
|
||||
|
@ -179,5 +185,5 @@ export async function listMetricDefinitions(
|
|||
accountName: string
|
||||
): Promise<Types.MetricDefinitionsListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/metricDefinitions`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists the Gremlin databases under an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function listGremlinDatabases(
|
|||
accountName: string
|
||||
): Promise<Types.GremlinDatabaseListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -27,7 +27,7 @@ export async function getGremlinDatabase(
|
|||
databaseName: string
|
||||
): Promise<Types.GremlinDatabaseGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB Gremlin database */
|
||||
|
@ -39,7 +39,7 @@ export async function createUpdateGremlinDatabase(
|
|||
body: Types.GremlinDatabaseCreateUpdateParameters
|
||||
): Promise<Types.GremlinDatabaseGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB Gremlin database. */
|
||||
|
@ -50,7 +50,7 @@ export async function deleteGremlinDatabase(
|
|||
databaseName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -61,7 +61,7 @@ export async function getGremlinDatabaseThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB Gremlin database */
|
||||
|
@ -73,7 +73,7 @@ export async function updateGremlinDatabaseThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale */
|
||||
|
@ -84,7 +84,7 @@ export async function migrateGremlinDatabaseToAutoscale(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput */
|
||||
|
@ -95,7 +95,7 @@ export async function migrateGremlinDatabaseToManualThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the Gremlin graph under an existing Azure Cosmos DB database account. */
|
||||
|
@ -106,7 +106,7 @@ export async function listGremlinGraphs(
|
|||
databaseName: string
|
||||
): Promise<Types.GremlinGraphListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Gremlin graph under an existing Azure Cosmos DB database account. */
|
||||
|
@ -118,7 +118,7 @@ export async function getGremlinGraph(
|
|||
graphName: string
|
||||
): Promise<Types.GremlinGraphGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB Gremlin graph */
|
||||
|
@ -131,7 +131,7 @@ export async function createUpdateGremlinGraph(
|
|||
body: Types.GremlinGraphCreateUpdateParameters
|
||||
): Promise<Types.GremlinGraphGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB Gremlin graph. */
|
||||
|
@ -143,7 +143,7 @@ export async function deleteGremlinGraph(
|
|||
graphName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -155,7 +155,7 @@ export async function getGremlinGraphThroughput(
|
|||
graphName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB Gremlin graph */
|
||||
|
@ -168,7 +168,7 @@ export async function updateGremlinGraphThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale */
|
||||
|
@ -180,7 +180,7 @@ export async function migrateGremlinGraphToAutoscale(
|
|||
graphName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput */
|
||||
|
@ -192,5 +192,5 @@ export async function migrateGremlinGraphToManualThroughput(
|
|||
graphName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/gremlinDatabases/${databaseName}/graphs/${graphName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists the MongoDB databases under an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function listMongoDBDatabases(
|
|||
accountName: string
|
||||
): Promise<Types.MongoDBDatabaseListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -27,7 +27,7 @@ export async function getMongoDBDatabase(
|
|||
databaseName: string
|
||||
): Promise<Types.MongoDBDatabaseGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or updates Azure Cosmos DB MongoDB database */
|
||||
|
@ -39,7 +39,7 @@ export async function createUpdateMongoDBDatabase(
|
|||
body: Types.MongoDBDatabaseCreateUpdateParameters
|
||||
): Promise<Types.MongoDBDatabaseGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB MongoDB database. */
|
||||
|
@ -50,7 +50,7 @@ export async function deleteMongoDBDatabase(
|
|||
databaseName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -61,7 +61,7 @@ export async function getMongoDBDatabaseThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of the an Azure Cosmos DB MongoDB database */
|
||||
|
@ -73,7 +73,7 @@ export async function updateMongoDBDatabaseThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale */
|
||||
|
@ -84,7 +84,7 @@ export async function migrateMongoDBDatabaseToAutoscale(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput */
|
||||
|
@ -95,7 +95,7 @@ export async function migrateMongoDBDatabaseToManualThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the MongoDB collection under an existing Azure Cosmos DB database account. */
|
||||
|
@ -106,7 +106,7 @@ export async function listMongoDBCollections(
|
|||
databaseName: string
|
||||
): Promise<Types.MongoDBCollectionListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the MongoDB collection under an existing Azure Cosmos DB database account. */
|
||||
|
@ -118,7 +118,7 @@ export async function getMongoDBCollection(
|
|||
collectionName: string
|
||||
): Promise<Types.MongoDBCollectionGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB MongoDB Collection */
|
||||
|
@ -131,7 +131,7 @@ export async function createUpdateMongoDBCollection(
|
|||
body: Types.MongoDBCollectionCreateUpdateParameters
|
||||
): Promise<Types.MongoDBCollectionGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB MongoDB Collection. */
|
||||
|
@ -143,7 +143,7 @@ export async function deleteMongoDBCollection(
|
|||
collectionName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -155,7 +155,7 @@ export async function getMongoDBCollectionThroughput(
|
|||
collectionName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update the RUs per second of an Azure Cosmos DB MongoDB collection */
|
||||
|
@ -168,7 +168,7 @@ export async function updateMongoDBCollectionThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale */
|
||||
|
@ -180,7 +180,7 @@ export async function migrateMongoDBCollectionToAutoscale(
|
|||
collectionName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput */
|
||||
|
@ -192,5 +192,5 @@ export async function migrateMongoDBCollectionToManualThroughput(
|
|||
collectionName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/mongodbDatabases/${databaseName}/collections/${collectionName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists all of the available Cosmos DB Resource Provider operations. */
|
||||
export async function list(): Promise<Types.OperationListResult> {
|
||||
const path = `/providers/Microsoft.DocumentDB/operations`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given partition key range id. */
|
||||
|
@ -19,5 +19,5 @@ export async function listMetrics(
|
|||
partitionKeyRangeId: string
|
||||
): Promise<Types.PartitionMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given partition key range id and region. */
|
||||
|
@ -20,5 +20,5 @@ export async function listMetrics(
|
|||
partitionKeyRangeId: string
|
||||
): Promise<Types.PartitionMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/region/${region}/databases/${databaseRid}/collections/${collectionRid}/partitionKeyRangeId/${partitionKeyRangeId}/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data */
|
||||
|
@ -16,5 +16,5 @@ export async function listMetrics(
|
|||
accountName: string
|
||||
): Promise<Types.PercentileMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/percentile/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given account, source and target region. This url is only for PBS and Replication Latency data */
|
||||
|
@ -18,5 +18,5 @@ export async function listMetrics(
|
|||
targetRegion: string
|
||||
): Promise<Types.PercentileMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sourceRegion/${sourceRegion}/targetRegion/${targetRegion}/percentile/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data */
|
||||
|
@ -17,5 +17,5 @@ export async function listMetrics(
|
|||
targetRegion: string
|
||||
): Promise<Types.PercentileMetricListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/targetRegion/${targetRegion}/percentile/metrics`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists the SQL databases under an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function listSqlDatabases(
|
|||
accountName: string
|
||||
): Promise<Types.SqlDatabaseListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -27,7 +27,7 @@ export async function getSqlDatabase(
|
|||
databaseName: string
|
||||
): Promise<Types.SqlDatabaseGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB SQL database */
|
||||
|
@ -39,7 +39,7 @@ export async function createUpdateSqlDatabase(
|
|||
body: Types.SqlDatabaseCreateUpdateParameters
|
||||
): Promise<Types.SqlDatabaseGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB SQL database. */
|
||||
|
@ -50,7 +50,7 @@ export async function deleteSqlDatabase(
|
|||
databaseName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -61,7 +61,7 @@ export async function getSqlDatabaseThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB SQL database */
|
||||
|
@ -73,7 +73,7 @@ export async function updateSqlDatabaseThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale */
|
||||
|
@ -84,7 +84,7 @@ export async function migrateSqlDatabaseToAutoscale(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput */
|
||||
|
@ -95,7 +95,7 @@ export async function migrateSqlDatabaseToManualThroughput(
|
|||
databaseName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the SQL container under an existing Azure Cosmos DB database account. */
|
||||
|
@ -106,7 +106,7 @@ export async function listSqlContainers(
|
|||
databaseName: string
|
||||
): Promise<Types.SqlContainerListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL container under an existing Azure Cosmos DB database account. */
|
||||
|
@ -118,7 +118,7 @@ export async function getSqlContainer(
|
|||
containerName: string
|
||||
): Promise<Types.SqlContainerGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB SQL container */
|
||||
|
@ -131,7 +131,7 @@ export async function createUpdateSqlContainer(
|
|||
body: Types.SqlContainerCreateUpdateParameters
|
||||
): Promise<Types.SqlContainerGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB SQL container. */
|
||||
|
@ -143,7 +143,7 @@ export async function deleteSqlContainer(
|
|||
containerName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. */
|
||||
|
@ -155,7 +155,7 @@ export async function getSqlContainerThroughput(
|
|||
containerName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB SQL container */
|
||||
|
@ -168,7 +168,7 @@ export async function updateSqlContainerThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale */
|
||||
|
@ -180,7 +180,7 @@ export async function migrateSqlContainerToAutoscale(
|
|||
containerName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput */
|
||||
|
@ -192,7 +192,7 @@ export async function migrateSqlContainerToManualThroughput(
|
|||
containerName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. */
|
||||
|
@ -204,7 +204,7 @@ export async function listSqlStoredProcedures(
|
|||
containerName: string
|
||||
): Promise<Types.SqlStoredProcedureListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. */
|
||||
|
@ -217,7 +217,7 @@ export async function getSqlStoredProcedure(
|
|||
storedProcedureName: string
|
||||
): Promise<Types.SqlStoredProcedureGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB SQL storedProcedure */
|
||||
|
@ -231,7 +231,7 @@ export async function createUpdateSqlStoredProcedure(
|
|||
body: Types.SqlStoredProcedureCreateUpdateParameters
|
||||
): Promise<Types.SqlStoredProcedureGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB SQL storedProcedure. */
|
||||
|
@ -244,7 +244,7 @@ export async function deleteSqlStoredProcedure(
|
|||
storedProcedureName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/storedProcedures/${storedProcedureName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
|
||||
|
@ -256,7 +256,7 @@ export async function listSqlUserDefinedFunctions(
|
|||
containerName: string
|
||||
): Promise<Types.SqlUserDefinedFunctionListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. */
|
||||
|
@ -269,7 +269,7 @@ export async function getSqlUserDefinedFunction(
|
|||
userDefinedFunctionName: string
|
||||
): Promise<Types.SqlUserDefinedFunctionGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB SQL userDefinedFunction */
|
||||
|
@ -283,7 +283,7 @@ export async function createUpdateSqlUserDefinedFunction(
|
|||
body: Types.SqlUserDefinedFunctionCreateUpdateParameters
|
||||
): Promise<Types.SqlUserDefinedFunctionGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB SQL userDefinedFunction. */
|
||||
|
@ -296,7 +296,7 @@ export async function deleteSqlUserDefinedFunction(
|
|||
userDefinedFunctionName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/userDefinedFunctions/${userDefinedFunctionName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Lists the SQL trigger under an existing Azure Cosmos DB database account. */
|
||||
|
@ -308,7 +308,7 @@ export async function listSqlTriggers(
|
|||
containerName: string
|
||||
): Promise<Types.SqlTriggerListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL trigger under an existing Azure Cosmos DB database account. */
|
||||
|
@ -321,7 +321,7 @@ export async function getSqlTrigger(
|
|||
triggerName: string
|
||||
): Promise<Types.SqlTriggerGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB SQL trigger */
|
||||
|
@ -335,7 +335,7 @@ export async function createUpdateSqlTrigger(
|
|||
body: Types.SqlTriggerCreateUpdateParameters
|
||||
): Promise<Types.SqlTriggerGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB SQL trigger. */
|
||||
|
@ -348,5 +348,5 @@ export async function deleteSqlTrigger(
|
|||
triggerName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases/${databaseName}/containers/${containerName}/triggers/${triggerName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
import { config } from "../../../../Config";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
const apiVersion = "2020-04-01";
|
||||
|
||||
/* Lists the Tables under an existing Azure Cosmos DB database account. */
|
||||
|
@ -16,7 +16,7 @@ export async function listTables(
|
|||
accountName: string
|
||||
): Promise<Types.TableListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the Tables under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -27,7 +27,7 @@ export async function getTable(
|
|||
tableName: string
|
||||
): Promise<Types.TableGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Create or update an Azure Cosmos DB Table */
|
||||
|
@ -39,7 +39,7 @@ export async function createUpdateTable(
|
|||
body: Types.TableCreateUpdateParameters
|
||||
): Promise<Types.TableGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Deletes an existing Azure Cosmos DB Table. */
|
||||
|
@ -50,7 +50,7 @@ export async function deleteTable(
|
|||
tableName: string
|
||||
): Promise<void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
@ -61,7 +61,7 @@ export async function getTableThroughput(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Update RUs per second of an Azure Cosmos DB Table */
|
||||
|
@ -73,7 +73,7 @@ export async function updateTableThroughput(
|
|||
body: Types.ThroughputSettingsUpdateParameters
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: JSON.stringify(body) });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Table from manual throughput to autoscale */
|
||||
|
@ -84,7 +84,7 @@ export async function migrateTableToAutoscale(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default/migrateToAutoscale`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
||||
/* Migrate an Azure Cosmos DB Table from autoscale to manual throughput */
|
||||
|
@ -95,5 +95,5 @@ export async function migrateTableToManualThroughput(
|
|||
tableName: string
|
||||
): Promise<Types.ThroughputSettingsGetResults | void> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/tables/${tableName}/throughputSettings/default/migrateToManualThroughput`;
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ Instead, generate ARM clients that consume this function with stricter typing.
|
|||
|
||||
*/
|
||||
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import promiseRetry, { AbortError } from "p-retry";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
interface ErrorResponse {
|
||||
error: {
|
||||
|
@ -34,7 +34,7 @@ export async function armRequest<T>({ host, path, apiVersion, method, body: requ
|
|||
const response = await window.fetch(url.href, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: CosmosClient.authorizationToken()
|
||||
Authorization: userContext.authorizationToken
|
||||
},
|
||||
body: requestBody ? JSON.stringify(requestBody) : undefined
|
||||
});
|
||||
|
@ -79,7 +79,7 @@ interface OperationResponse {
|
|||
async function getOperationStatus(operationStatusUrl: string) {
|
||||
const response = await window.fetch(operationStatusUrl, {
|
||||
headers: {
|
||||
Authorization: CosmosClient.authorizationToken()
|
||||
Authorization: userContext.authorizationToken
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DatabaseAccount } from "../../Contracts/DataModels";
|
||||
import { Platform } from "../../Config";
|
||||
import { Platform } from "../../ConfigContext";
|
||||
|
||||
export interface StartUploadMessageParams {
|
||||
files: FileList;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import "babel-polyfill";
|
||||
import { DocumentClientParams, UploadDetailsRecord, UploadDetails } from "./definitions";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { config } from "../../Config";
|
||||
import { client } from "../../Common/CosmosClient";
|
||||
import { configContext, updateConfigContext } from "../../ConfigContext";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
let numUploadsSuccessful = 0;
|
||||
let numUploadsFailed = 0;
|
||||
|
@ -30,11 +31,15 @@ onmessage = (event: MessageEvent) => {
|
|||
const clientParams: DocumentClientParams = event.data.documentClientParams;
|
||||
containerId = clientParams.containerId;
|
||||
databaseId = clientParams.databaseId;
|
||||
CosmosClient.masterKey(clientParams.masterKey);
|
||||
CosmosClient.endpoint(clientParams.endpoint);
|
||||
CosmosClient.accessToken(clientParams.accessToken);
|
||||
CosmosClient.databaseAccount(clientParams.databaseAccount);
|
||||
config.platform = clientParams.platform;
|
||||
updateUserContext({
|
||||
masterKey: clientParams.masterKey,
|
||||
endpoint: clientParams.endpoint,
|
||||
accessToken: clientParams.accessToken,
|
||||
databaseAccount: clientParams.databaseAccount
|
||||
});
|
||||
updateConfigContext({
|
||||
platform: clientParams.platform
|
||||
});
|
||||
if (!!files && files.length > 0) {
|
||||
numFiles = files.length;
|
||||
for (let i = 0; i < numFiles; i++) {
|
||||
|
@ -78,7 +83,7 @@ function createDocumentsFromFile(fileName: string, documentContent: string): voi
|
|||
try {
|
||||
const content = JSON.parse(documentContent);
|
||||
const triggerCreateDocument: (documentContent: any) => void = (documentContent: any) => {
|
||||
CosmosClient.client()
|
||||
client()
|
||||
.database(databaseId)
|
||||
.container(containerId)
|
||||
.items.create(documentContent)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"./src/Common/ThemeUtility.ts",
|
||||
"./src/Common/UrlUtility.ts",
|
||||
"./src/Common/dataAccess/sendNotificationForError.ts",
|
||||
"./src/Config.ts",
|
||||
"./src/ConfigContext.ts",
|
||||
"./src/Contracts/ActionContracts.ts",
|
||||
"./src/Contracts/DataModels.ts",
|
||||
"./src/Contracts/Diagnostics.ts",
|
||||
|
@ -65,6 +65,7 @@
|
|||
"./src/Shared/Telemetry/TelemetryConstants.ts",
|
||||
"./src/Shared/Telemetry/TelemetryProcessor.ts",
|
||||
"./src/Shared/appInsights.ts",
|
||||
"./src/UserContext.ts",
|
||||
"./src/Utils/GitHubUtils.ts",
|
||||
"./src/Utils/MessageValidation.ts",
|
||||
"./src/Utils/OfferUtils.ts",
|
||||
|
|
|
@ -226,7 +226,7 @@ async function main() {
|
|||
const outputClient: string[] = [""];
|
||||
outputClient.push(`import { armRequest } from "../../request"\n`);
|
||||
outputClient.push(`import * as Types from "./types"\n`);
|
||||
outputClient.push(`import { config } from "../../../../Config";\n`);
|
||||
outputClient.push(`import { configContext } from "../../../../ConfigContext";\n`);
|
||||
outputClient.push(`const apiVersion = "${version}"\n\n`);
|
||||
for (const path of clients[clientName].paths) {
|
||||
for (const method in schema.paths[path]) {
|
||||
|
@ -244,7 +244,7 @@ async function main() {
|
|||
${bodyParam(bodyParameter, "Types")}
|
||||
) : Promise<${responseType(operation, "Types")}> {
|
||||
const path = \`${path.replace(/{/g, "${")}\`
|
||||
return armRequest({ host: config.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${
|
||||
bodyParameter ? "body: JSON.stringify(body)" : ""
|
||||
} })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue