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