Compare commits

..

1 Commits

Author SHA1 Message Date
Steve Faulkner
f738723f5a Remove ExplorerOptions 2020-08-12 21:43:58 -05:00
42 changed files with 489 additions and 720 deletions

View File

@@ -1,46 +0,0 @@
import "jquery";
import * as Q from "q";
import * as DataModels from "../Contracts/DataModels";
import * as ViewModels from "../Contracts/ViewModels";
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
import { userContext } from "../UserContext";
export class NotificationsClientBase {
private _extensionEndpoint: string;
private _notificationsApiSuffix: string;
protected constructor(notificationsApiSuffix: string) {
this._notificationsApiSuffix = notificationsApiSuffix;
}
public fetchNotifications(): Q.Promise<DataModels.Notification[]> {
const deferred: Q.Deferred<DataModels.Notification[]> = Q.defer<DataModels.Notification[]>();
const databaseAccount = userContext.databaseAccount;
const subscriptionId = userContext.subscriptionId;
const resourceGroup = userContext.resourceGroup;
const url = `${this._extensionEndpoint}${this._notificationsApiSuffix}?accountName=${databaseAccount.name}&subscriptionId=${subscriptionId}&resourceGroup=${resourceGroup}`;
const authorizationHeader: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
const headers: any = {};
headers[authorizationHeader.header] = authorizationHeader.token;
$.ajax({
url: url,
type: "GET",
headers: headers,
cache: false
}).then(
(notifications: DataModels.Notification[], textStatus: string, xhr: JQueryXHR<any>) => {
deferred.resolve(notifications);
},
(xhr: JQueryXHR<any>, textStatus: string, error: any) => {
deferred.reject(xhr.responseText);
}
);
return deferred.promise;
}
public setExtensionEndpoint(extensionEndpoint: string): void {
this._extensionEndpoint = extensionEndpoint;
}
}

View File

@@ -82,7 +82,6 @@ import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils";
import UserDefinedFunction from "./Tree/UserDefinedFunction"; import UserDefinedFunction from "./Tree/UserDefinedFunction";
import StoredProcedure from "./Tree/StoredProcedure"; import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger"; import Trigger from "./Tree/Trigger";
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";
@@ -98,7 +97,6 @@ enum ShareAccessToggleState {
} }
interface ExplorerOptions { interface ExplorerOptions {
notificationsClient: NotificationsClientBase;
isEmulator: boolean; isEmulator: boolean;
} }
interface AdHocAccessData { interface AdHocAccessData {
@@ -133,7 +131,6 @@ export default class Explorer {
public isPreferredApiTable: ko.Computed<boolean>; public isPreferredApiTable: ko.Computed<boolean>;
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>; public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
public isServerlessEnabled: ko.Computed<boolean>; public isServerlessEnabled: ko.Computed<boolean>;
public isEmulator: boolean;
public isAccountReady: ko.Observable<boolean>; public isAccountReady: ko.Observable<boolean>;
public canSaveQueries: ko.Computed<boolean>; public canSaveQueries: ko.Computed<boolean>;
public features: ko.Observable<any>; public features: ko.Observable<any>;
@@ -141,7 +138,6 @@ export default class Explorer {
public extensionEndpoint: ko.Observable<string>; public extensionEndpoint: ko.Observable<string>;
public armEndpoint: ko.Observable<string>; public armEndpoint: ko.Observable<string>;
public isTryCosmosDBSubscription: ko.Observable<boolean>; public isTryCosmosDBSubscription: ko.Observable<boolean>;
public notificationsClient: NotificationsClientBase;
public queriesClient: QueriesClient; public queriesClient: QueriesClient;
public tableDataClient: TableDataClient; public tableDataClient: TableDataClient;
public splitter: Splitter; public splitter: Splitter;
@@ -269,7 +265,7 @@ export default class Explorer {
private static readonly MaxNbDatabasesToAutoExpand = 5; private static readonly MaxNbDatabasesToAutoExpand = 5;
constructor(options: ExplorerOptions) { constructor() {
const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, { const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, {
dataExplorerArea: Constants.Areas.ResourceTree dataExplorerArea: Constants.Areas.ResourceTree
}); });
@@ -375,8 +371,6 @@ export default class Explorer {
} }
}); });
this.memoryUsageInfo = ko.observable<DataModels.MemoryUsageInfo>(); this.memoryUsageInfo = ko.observable<DataModels.MemoryUsageInfo>();
this.notificationsClient = options.notificationsClient;
this.isEmulator = options.isEmulator;
this.features = ko.observable(); this.features = ko.observable();
this.serverId = ko.observable<string>(); this.serverId = ko.observable<string>();
@@ -1939,7 +1933,6 @@ export default class Explorer {
this.serverId(inputs.serverId); this.serverId(inputs.serverId);
this.extensionEndpoint(inputs.extensionEndpoint || ""); this.extensionEndpoint(inputs.extensionEndpoint || "");
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT)); this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
this.notificationsClient.setExtensionEndpoint(this.extensionEndpoint());
this.databaseAccount(databaseAccount); this.databaseAccount(databaseAccount);
this.subscriptionType(inputs.subscriptionType); this.subscriptionType(inputs.subscriptionType);
this.quotaId(inputs.quotaId); this.quotaId(inputs.quotaId);

View File

@@ -87,26 +87,13 @@ describe("getPkIdFromDocumentId", () => {
expect(GraphExplorer.getPkIdFromDocumentId(doc, "mypk")).toEqual("['pkvalue', 'id']"); expect(GraphExplorer.getPkIdFromDocumentId(doc, "mypk")).toEqual("['pkvalue', 'id']");
}); });
it("should create pkid pair from partitioned graph (pk as number)", () => {
const doc = createFakeDoc({ id: "id", mypk: 234 });
expect(GraphExplorer.getPkIdFromDocumentId(doc, "mypk")).toEqual("[234, 'id']");
});
it("should create pkid pair from partitioned graph (pk as valid array value)", () => { it("should create pkid pair from partitioned graph (pk as valid array value)", () => {
const doc = createFakeDoc({ id: "id", mypk: [{ id: "someid", _value: "pkvalue" }] }); const doc = createFakeDoc({ id: "id", mypk: [{ id: "someid", _value: "pkvalue" }] });
expect(GraphExplorer.getPkIdFromDocumentId(doc, "mypk")).toEqual("['pkvalue', 'id']"); expect(GraphExplorer.getPkIdFromDocumentId(doc, "mypk")).toEqual("['pkvalue', 'id']");
}); });
it("should error if id is not a string or number", () => { it("should error if id is not a string", () => {
let doc = createFakeDoc({ id: { foo: 1 } }); const doc = createFakeDoc({ id: { foo: 1 } });
try {
GraphExplorer.getPkIdFromDocumentId(doc, undefined);
expect(true).toBe(false);
} catch (e) {
expect(true).toBe(true);
}
doc = createFakeDoc({ id: true });
try { try {
GraphExplorer.getPkIdFromDocumentId(doc, undefined); GraphExplorer.getPkIdFromDocumentId(doc, undefined);
expect(true).toBe(false); expect(true).toBe(false);
@@ -115,8 +102,16 @@ describe("getPkIdFromDocumentId", () => {
} }
}); });
it("should error if pk is empty array", () => { it("should error if pk not string nor non-empty array", () => {
let doc = createFakeDoc({ mypk: [] }); let doc = createFakeDoc({ mypk: { foo: 1 } });
try {
GraphExplorer.getPkIdFromDocumentId(doc, "mypk");
} catch (e) {
expect(true).toBe(true);
}
doc = createFakeDoc({ mypk: [] });
try { try {
GraphExplorer.getPkIdFromDocumentId(doc, "mypk"); GraphExplorer.getPkIdFromDocumentId(doc, "mypk");
expect(true).toBe(false); expect(true).toBe(false);

View File

@@ -1371,7 +1371,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
if (collectionPartitionKeyProperty && d.hasOwnProperty(collectionPartitionKeyProperty)) { if (collectionPartitionKeyProperty && d.hasOwnProperty(collectionPartitionKeyProperty)) {
let pk = (d as any)[collectionPartitionKeyProperty]; let pk = (d as any)[collectionPartitionKeyProperty];
if (typeof pk !== "string" && typeof pk !== "number") { if (typeof pk !== "string") {
if (Array.isArray(pk) && pk.length > 0) { if (Array.isArray(pk) && pk.length > 0) {
// pk is [{ id: 'id', _value: 'value' }] // pk is [{ id: 'id', _value: 'value' }]
pk = pk[0]["_value"]; pk = pk[0]["_value"];

View File

@@ -194,7 +194,7 @@ export class CommandBarComponentButtonFactory {
buttons.push(fullScreenButton); buttons.push(fullScreenButton);
} }
if (!container.hasOwnProperty("isEmulator") || !container.isEmulator) { if (configContext.platform !== Platform.Emulator) {
const label = "Feedback"; const label = "Feedback";
const feedbackButtonOptions: CommandButtonComponentProps = { const feedbackButtonOptions: CommandButtonComponentProps = {
iconSrc: FeedbackIcon, iconSrc: FeedbackIcon,

View File

@@ -40,7 +40,7 @@ describe("Add Collection Pane", () => {
}; };
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
}); });

View File

@@ -329,7 +329,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
this.canRequestSupport = ko.pureComputed(() => { this.canRequestSupport = ko.pureComputed(() => {
if ( if (
!this.container.isEmulator && configContext.platform !== Platform.Emulator &&
!this.container.isTryCosmosDBSubscription() && !this.container.isTryCosmosDBSubscription() &&
this.container.getPlatformType() !== PlatformType.Portal this.container.getPlatformType() !== PlatformType.Portal
) { ) {
@@ -341,7 +341,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
}); });
this.costsVisible = ko.pureComputed(() => { this.costsVisible = ko.pureComputed(() => {
return !this.container.isEmulator; return configContext.platform !== Platform.Emulator;
}); });
this.maxCollectionsReached = ko.computed<boolean>(() => { this.maxCollectionsReached = ko.computed<boolean>(() => {

View File

@@ -40,10 +40,7 @@ describe("Add Database Pane", () => {
}; };
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ explorer = new Explorer();
notificationsClient: null,
isEmulator: false
});
}); });
it("should be true if subscription type is Benefits", () => { it("should be true if subscription type is Benefits", () => {

View File

@@ -17,6 +17,7 @@ import { ContextualPaneBase } from "./ContextualPaneBase";
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"; import { userContext } from "../../UserContext";
import { configContext, Platform } from "../../ConfigContext";
export default class AddDatabasePane extends ContextualPaneBase { export default class AddDatabasePane extends ContextualPaneBase {
public defaultExperience: ko.Computed<string>; public defaultExperience: ko.Computed<string>;
@@ -179,7 +180,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
this.canRequestSupport = ko.pureComputed(() => { this.canRequestSupport = ko.pureComputed(() => {
if ( if (
!this.container.isEmulator && configContext.platform !== Platform.Emulator &&
!this.container.isTryCosmosDBSubscription() && !this.container.isTryCosmosDBSubscription() &&
this.container.getPlatformType() !== PlatformType.Portal this.container.getPlatformType() !== PlatformType.Portal
) { ) {
@@ -202,7 +203,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
}); });
this.costsVisible = ko.pureComputed(() => { this.costsVisible = ko.pureComputed(() => {
return !this.container.isEmulator; return configContext.platform !== Platform.Emulator;
}); });
this.throughputSpendAckVisible = ko.pureComputed<boolean>(() => { this.throughputSpendAckVisible = ko.pureComputed<boolean>(() => {
@@ -421,7 +422,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
startKey: number startKey: number
): void { ): void {
if (EnvironmentUtility.isAadUser()) { if (EnvironmentUtility.isAadUser()) {
this._createKeyspaceUsingRP(createDatabaseParameters, autoPilotSettings, startKey); this._createKeyspaceUsingRP(this.container.armEndpoint(), createDatabaseParameters, autoPilotSettings, startKey);
} else { } else {
this._createKeyspaceUsingProxy(createDatabaseParameters.offerThroughput, startKey); this._createKeyspaceUsingProxy(createDatabaseParameters.offerThroughput, startKey);
} }
@@ -450,11 +451,12 @@ export default class AddDatabasePane extends ContextualPaneBase {
} }
private _createKeyspaceUsingRP( private _createKeyspaceUsingRP(
armEndpoint: string,
createKeyspaceParameters: DataModels.RpParameters, createKeyspaceParameters: DataModels.RpParameters,
autoPilotSettings: DataModels.RpOptions, autoPilotSettings: DataModels.RpOptions,
startKey: number startKey: number
): void { ): void {
AddDbUtilities.createCassandraKeyspace(createKeyspaceParameters, autoPilotSettings).then(() => { AddDbUtilities.createCassandraKeyspace(armEndpoint, createKeyspaceParameters, autoPilotSettings).then(() => {
Promise.all([refreshCachedOffers(), refreshCachedResources()]).then(() => { Promise.all([refreshCachedOffers(), refreshCachedResources()]).then(() => {
this._onCreateDatabaseSuccess(createKeyspaceParameters.offerThroughput, startKey); this._onCreateDatabaseSuccess(createKeyspaceParameters.offerThroughput, startKey);
}); });

View File

@@ -12,6 +12,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
import { CassandraAPIDataClient } from "../Tables/TableDataClient"; import { CassandraAPIDataClient } from "../Tables/TableDataClient";
import { ContextualPaneBase } from "./ContextualPaneBase"; import { ContextualPaneBase } from "./ContextualPaneBase";
import { HashMap } from "../../Common/HashMap"; import { HashMap } from "../../Common/HashMap";
import { configContext, Platform } from "../../ConfigContext";
export default class CassandraAddCollectionPane extends ContextualPaneBase { export default class CassandraAddCollectionPane extends ContextualPaneBase {
public createTableQuery: ko.Observable<string>; public createTableQuery: ko.Observable<string>;
@@ -231,11 +232,11 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
}); });
this.costsVisible = ko.pureComputed(() => { this.costsVisible = ko.pureComputed(() => {
return !this.container.isEmulator; return configContext.platform !== Platform.Emulator;
}); });
this.canRequestSupport = ko.pureComputed(() => { this.canRequestSupport = ko.pureComputed(() => {
if (!this.container.isEmulator && !this.container.isTryCosmosDBSubscription()) { if (configContext.platform !== Platform.Emulator && !this.container.isTryCosmosDBSubscription()) {
const offerThroughput: number = this.throughput(); const offerThroughput: number = this.throughput();
return offerThroughput <= 100000; return offerThroughput <= 100000;
} }

View File

@@ -17,7 +17,7 @@ describe("Delete Collection Confirmation Pane", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
}); });
it("should be true if 1 database and 1 collection", () => { it("should be true if 1 database and 1 collection", () => {
@@ -56,7 +56,7 @@ describe("Delete Collection Confirmation Pane", () => {
describe("shouldRecordFeedback()", () => { describe("shouldRecordFeedback()", () => {
it("should return true if last collection and database does not have shared throughput else false", () => { it("should return true if last collection and database does not have shared throughput else false", () => {
let fakeExplorer = new Explorer({ notificationsClient: null, isEmulator: false }); let fakeExplorer = new Explorer();
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false); fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
fakeExplorer.refreshAllDatabases = () => Q.resolve(); fakeExplorer.refreshAllDatabases = () => Q.resolve();

View File

@@ -22,7 +22,7 @@ describe("Delete Database Confirmation Pane", () => {
}); });
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
}); });
it("should be true if only 1 database", () => { it("should be true if only 1 database", () => {

View File

@@ -7,7 +7,7 @@ describe("Settings Pane", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
}); });
it("should be true for SQL API", () => { it("should be true for SQL API", () => {

View File

@@ -6,7 +6,7 @@ import Explorer from "../Explorer";
jest.mock("../Explorer"); jest.mock("../Explorer");
const createExplorer = () => { const createExplorer = () => {
const mock = new Explorer({} as any); const mock = new Explorer();
mock.selectedNode = ko.observable(); mock.selectedNode = ko.observable();
mock.isNotebookEnabled = ko.observable(false); mock.isNotebookEnabled = ko.observable(false);
mock.addCollectionText = ko.observable("add collection"); mock.addCollectionText = ko.observable("add collection");

View File

@@ -20,6 +20,7 @@ import { updateOffer } from "../../Common/DocumentClientUtilityBase";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import { userContext } from "../../UserContext"; import { userContext } from "../../UserContext";
import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit"; import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit";
import { configContext, Platform } from "../../ConfigContext";
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.
@@ -196,7 +197,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
}); });
this.costsVisible = ko.computed(() => { this.costsVisible = ko.computed(() => {
return !this.container.isEmulator; return configContext.platform !== Platform.Emulator;
}); });
this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>( this.shouldDisplayPortalUsePrompt = ko.pureComputed<boolean>(
@@ -207,7 +208,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
); );
this.canRequestSupport = ko.pureComputed(() => { this.canRequestSupport = ko.pureComputed(() => {
if ( if (
!!this.container.isEmulator || configContext.platform === Platform.Emulator ||
this.container.getPlatformType() === PlatformType.Hosted || this.container.getPlatformType() === PlatformType.Hosted ||
this.canThroughputExceedMaximumValue() this.canThroughputExceedMaximumValue()
) { ) {

View File

@@ -27,15 +27,9 @@ describe("Documents tab", () => {
}); });
describe("showPartitionKey", () => { describe("showPartitionKey", () => {
const explorer = new Explorer({ const explorer = new Explorer();
notificationsClient: null,
isEmulator: false
});
const mongoExplorer = new Explorer({ const mongoExplorer = new Explorer();
notificationsClient: null,
isEmulator: false
});
mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB); mongoExplorer.defaultExperience(Constants.DefaultAccountExperience.MongoDB);
const collectionWithoutPartitionKey = <ViewModels.Collection>(<unknown>{ const collectionWithoutPartitionKey = <ViewModels.Collection>(<unknown>{

View File

@@ -49,7 +49,7 @@ describe("Query Tab", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
}); });
it("should be true for accounts using SQL API", () => { it("should be true for accounts using SQL API", () => {
@@ -69,7 +69,7 @@ describe("Query Tab", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
}); });
it("should be visible when using a supported API", () => { it("should be visible when using a supported API", () => {

View File

@@ -78,7 +78,7 @@ describe("Settings tab", () => {
}; };
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
}); });
@@ -177,7 +177,7 @@ describe("Settings tab", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
}); });
@@ -255,7 +255,7 @@ describe("Settings tab", () => {
let explorer: Explorer; let explorer: Explorer;
beforeEach(() => { beforeEach(() => {
explorer = new Explorer({ notificationsClient: null, isEmulator: false }); explorer = new Explorer();
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
}); });
@@ -336,10 +336,7 @@ describe("Settings tab", () => {
} }
function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) { function getCollection(defaultApi: string, partitionKeyOption: PartitionKeyOption) {
const explorer = new Explorer({ const explorer = new Explorer();
notificationsClient: null,
isEmulator: false
});
explorer.defaultExperience(defaultApi); explorer.defaultExperience(defaultApi);
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
@@ -471,10 +468,7 @@ describe("Settings tab", () => {
describe("AutoPilot", () => { describe("AutoPilot", () => {
function getCollection(autoPilotTier: DataModels.AutopilotTier) { function getCollection(autoPilotTier: DataModels.AutopilotTier) {
const explorer = new Explorer({ const explorer = new Explorer();
notificationsClient: null,
isEmulator: false
});
explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true); explorer.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
explorer.databaseAccount({ explorer.databaseAccount({

View File

@@ -21,6 +21,8 @@ import { updateOffer, updateCollection } from "../../Common/DocumentClientUtilit
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import { userContext } from "../../UserContext"; import { userContext } from "../../UserContext";
import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit"; import { updateOfferThroughputBeyondLimit } from "../../Common/dataAccess/updateOfferThroughputBeyondLimit";
import { config } from "process";
import { configContext, Platform } from "../../ConfigContext";
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.
@@ -454,7 +456,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
}); });
this.rupmVisible = ko.computed(() => { this.rupmVisible = ko.computed(() => {
if (this.container.isEmulator) { if (configContext.platform === Platform.Emulator) {
return false; return false;
} }
if (this.container.isFeatureEnabled(Constants.Features.enableRupm)) { if (this.container.isFeatureEnabled(Constants.Features.enableRupm)) {
@@ -484,7 +486,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
}); });
this.costsVisible = ko.computed(() => { this.costsVisible = ko.computed(() => {
return !this.container.isEmulator; return configContext.platform !== Platform.Emulator;
}); });
this.isTryCosmosDBSubscription = ko.computed<boolean>(() => { this.isTryCosmosDBSubscription = ko.computed<boolean>(() => {
@@ -500,7 +502,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
}); });
this.canRequestSupport = ko.pureComputed(() => { this.canRequestSupport = ko.pureComputed(() => {
if (this.container.isEmulator) { if (configContext.platform === Platform.Emulator) {
return false; return false;
} }
@@ -707,7 +709,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
} }
const isThroughputGreaterThanMaxRus = this.throughput() > this.maxRUs(); const isThroughputGreaterThanMaxRus = this.throughput() > this.maxRUs();
const isEmulator = this.container.isEmulator; const isEmulator = configContext.platform === Platform.Emulator;
if (isThroughputGreaterThanMaxRus && isEmulator) { if (isThroughputGreaterThanMaxRus && isEmulator) {
return false; return false;
} }
@@ -878,7 +880,8 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million && this.maxRUs() <= SharedConstants.CollectionCreation.DefaultCollectionRUs1Million &&
this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million; this.throughput() > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
const throughputExceedsMaxValue: boolean = !this.container.isEmulator && this.throughput() > this.maxRUs(); const throughputExceedsMaxValue: boolean =
configContext.platform !== Platform.Emulator && this.throughput() > this.maxRUs();
const ttlOptionDirty: boolean = this.timeToLive.editableIsDirty(); const ttlOptionDirty: boolean = this.timeToLive.editableIsDirty();
const ttlOrIndexingPolicyFieldsDirty: boolean = const ttlOrIndexingPolicyFieldsDirty: boolean =

View File

@@ -16,7 +16,7 @@ describe("Tabs manager tests", () => {
let documentsTab: DocumentsTab; let documentsTab: DocumentsTab;
beforeAll(() => { beforeAll(() => {
explorer = new Explorer({ notificationsClient: undefined, isEmulator: false }); explorer = new Explorer();
explorer.databaseAccount = ko.observable<DataModels.DatabaseAccount>({ explorer.databaseAccount = ko.observable<DataModels.DatabaseAccount>({
id: "test", id: "test",
name: "test", name: "test",

View File

@@ -559,7 +559,6 @@ export default class Collection implements ViewModels.Collection {
}); });
const tabTitle = !this.offer() ? "Settings" : "Scale & Settings"; const tabTitle = !this.offer() ? "Settings" : "Scale & Settings";
const pendingNotificationsPromise: Q.Promise<DataModels.Notification> = this._getPendingThroughputSplitNotification();
const matchingTabs = this.container.tabsManager.getTabs(ViewModels.CollectionTabKind.Settings, tab => { const matchingTabs = this.container.tabsManager.getTabs(ViewModels.CollectionTabKind.Settings, tab => {
return tab.collection && tab.collection.rid === this.rid; return tab.collection && tab.collection.rid === this.rid;
}); });
@@ -575,9 +574,8 @@ export default class Collection implements ViewModels.Collection {
tabTitle: tabTitle tabTitle: tabTitle
}); });
Q.all([pendingNotificationsPromise, this.readSettings()]).then( Q.all([this.readSettings()]).then(
(data: any) => { (data: any) => {
const pendingNotification: DataModels.Notification = data && data[0];
settingsTab = new SettingsTab({ settingsTab = new SettingsTab({
tabKind: ViewModels.CollectionTabKind.Settings, tabKind: ViewModels.CollectionTabKind.Settings,
title: !this.offer() ? "Settings" : "Scale & Settings", title: !this.offer() ? "Settings" : "Scale & Settings",
@@ -592,7 +590,6 @@ export default class Collection implements ViewModels.Collection {
onUpdateTabsButtons: this.container.onUpdateTabsButtons onUpdateTabsButtons: this.container.onUpdateTabsButtons
}); });
this.container.tabsManager.activateNewTab(settingsTab); this.container.tabsManager.activateNewTab(settingsTab);
settingsTab.pendingNotification(pendingNotification);
}, },
(error: any) => { (error: any) => {
TelemetryProcessor.traceFailure( TelemetryProcessor.traceFailure(
@@ -616,16 +613,7 @@ export default class Collection implements ViewModels.Collection {
} }
); );
} else { } else {
pendingNotificationsPromise.then( this.container.tabsManager.activateTab(settingsTab);
(pendingNotification: DataModels.Notification) => {
settingsTab.pendingNotification(pendingNotification);
this.container.tabsManager.activateTab(settingsTab);
},
(error: any) => {
settingsTab.pendingNotification(undefined);
this.container.tabsManager.activateTab(settingsTab);
}
);
} }
}; };
@@ -1283,48 +1271,6 @@ export default class Collection implements ViewModels.Collection {
return deferred.promise; return deferred.promise;
} }
private _getPendingThroughputSplitNotification(): Q.Promise<DataModels.Notification> {
if (!this.container) {
return Q.resolve(undefined);
}
const deferred: Q.Deferred<DataModels.Notification> = Q.defer<DataModels.Notification>();
this.container.notificationsClient.fetchNotifications().then(
(notifications: DataModels.Notification[]) => {
if (!notifications || notifications.length === 0) {
deferred.resolve(undefined);
return;
}
const pendingNotification = _.find(notifications, (notification: DataModels.Notification) => {
const throughputUpdateRegExp: RegExp = new RegExp("Throughput update (.*) in progress");
return (
notification.kind === "message" &&
notification.collectionName === this.id() &&
notification.description &&
throughputUpdateRegExp.test(notification.description)
);
});
deferred.resolve(pendingNotification);
},
(error: any) => {
Logger.logError(
JSON.stringify({
error: JSON.stringify(error),
accountName: this.container && this.container.databaseAccount(),
databaseName: this.databaseId,
collectionName: this.id()
}),
"Settings tree node"
);
deferred.resolve(undefined);
}
);
return deferred.promise;
}
private _logUploadDetailsInConsole(uploadDetails: UploadDetails): void { private _logUploadDetailsInConsole(uploadDetails: UploadDetails): void {
const uploadDetailsRecords: UploadDetailsRecord[] = uploadDetails.data; const uploadDetailsRecords: UploadDetailsRecord[] = uploadDetails.data;
const numFiles: number = uploadDetailsRecords.length; const numFiles: number = uploadDetailsRecords.length;

View File

@@ -52,7 +52,6 @@ export default class Database implements ViewModels.Database {
dataExplorerArea: Constants.Areas.ResourceTree dataExplorerArea: Constants.Areas.ResourceTree
}); });
const pendingNotificationsPromise: Q.Promise<DataModels.Notification> = this._getPendingThroughputSplitNotification();
const matchingTabs = this.container.tabsManager.getTabs( const matchingTabs = this.container.tabsManager.getTabs(
ViewModels.CollectionTabKind.DatabaseSettings, ViewModels.CollectionTabKind.DatabaseSettings,
tab => tab.rid === this.rid tab => tab.rid === this.rid
@@ -66,9 +65,8 @@ export default class Database implements ViewModels.Database {
dataExplorerArea: Constants.Areas.Tab, dataExplorerArea: Constants.Areas.Tab,
tabTitle: "Scale" tabTitle: "Scale"
}); });
Q.all([pendingNotificationsPromise, this.readSettings()]).then( Q.all([this.readSettings()]).then(
(data: any) => { () => {
const pendingNotification: DataModels.Notification = data && data[0];
settingsTab = new DatabaseSettingsTab({ settingsTab = new DatabaseSettingsTab({
tabKind: ViewModels.CollectionTabKind.DatabaseSettings, tabKind: ViewModels.CollectionTabKind.DatabaseSettings,
title: "Scale", title: "Scale",
@@ -83,7 +81,6 @@ export default class Database implements ViewModels.Database {
onUpdateTabsButtons: this.container.onUpdateTabsButtons onUpdateTabsButtons: this.container.onUpdateTabsButtons
}); });
settingsTab.pendingNotification(pendingNotification);
this.container.tabsManager.activateNewTab(settingsTab); this.container.tabsManager.activateNewTab(settingsTab);
}, },
(error: any) => { (error: any) => {
@@ -108,16 +105,7 @@ export default class Database implements ViewModels.Database {
} }
); );
} else { } else {
pendingNotificationsPromise.then( this.container.tabsManager.activateTab(settingsTab);
(pendingNotification: DataModels.Notification) => {
settingsTab.pendingNotification(pendingNotification);
this.container.tabsManager.activateTab(settingsTab);
},
(error: any) => {
settingsTab.pendingNotification(undefined);
this.container.tabsManager.activateTab(settingsTab);
}
);
} }
}; };
@@ -293,49 +281,6 @@ export default class Database implements ViewModels.Database {
return _.find(this.collections(), (collection: ViewModels.Collection) => collection.id() === collectionId); return _.find(this.collections(), (collection: ViewModels.Collection) => collection.id() === collectionId);
} }
private _getPendingThroughputSplitNotification(): Q.Promise<DataModels.Notification> {
if (!this.container) {
return Q.resolve(undefined);
}
const deferred: Q.Deferred<DataModels.Notification> = Q.defer<DataModels.Notification>();
this.container.notificationsClient.fetchNotifications().then(
(notifications: DataModels.Notification[]) => {
if (!notifications || notifications.length === 0) {
deferred.resolve(undefined);
return;
}
const pendingNotification = _.find(notifications, (notification: DataModels.Notification) => {
const throughputUpdateRegExp: RegExp = new RegExp("Throughput update (.*) in progress");
return (
notification.kind === "message" &&
!notification.collectionName &&
notification.databaseName === this.id() &&
notification.description &&
throughputUpdateRegExp.test(notification.description)
);
});
deferred.resolve(pendingNotification);
},
(error: any) => {
Logger.logError(
JSON.stringify({
error: JSON.stringify(error),
accountName: this.container && this.container.databaseAccount(),
databaseName: this.id(),
collectionName: this.id()
}),
"Settings tree node"
);
deferred.resolve(undefined);
}
);
return deferred.promise;
}
private getDeltaCollections( private getDeltaCollections(
updatedCollectionsList: DataModels.Collection[] updatedCollectionsList: DataModels.Collection[]
): { toAdd: DataModels.Collection[]; toDelete: Collection[] } { ): { toAdd: DataModels.Collection[]; toDelete: Collection[] } {

View File

@@ -2,14 +2,9 @@ import { AccountKind, TagNames, DefaultAccountExperience } from "../../Common/Co
import Explorer from "../../Explorer/Explorer"; import Explorer from "../../Explorer/Explorer";
import { NotificationsClient } from "./NotificationsClient";
export default class EmulatorExplorerFactory { export default class EmulatorExplorerFactory {
public static createExplorer(): Explorer { public static createExplorer(): Explorer {
const explorer: Explorer = new Explorer({ const explorer: Explorer = new Explorer();
notificationsClient: new NotificationsClient(),
isEmulator: true
});
explorer.databaseAccount({ explorer.databaseAccount({
name: "", name: "",
id: "", id: "",

View File

@@ -1,6 +1,24 @@
import EmulatorExplorerFactory from "./ExplorerFactory";
import Explorer from "../../Explorer/Explorer"; import Explorer from "../../Explorer/Explorer";
import { AccountKind, DefaultAccountExperience, TagNames } from "../../Common/Constants";
export function initializeExplorer(): Explorer { export function initializeExplorer(): Explorer {
return EmulatorExplorerFactory.createExplorer(); const explorer: Explorer = new Explorer();
explorer.databaseAccount({
name: "",
id: "",
location: "",
type: "",
kind: AccountKind.DocumentDB,
tags: {
[TagNames.defaultExperience]: DefaultAccountExperience.DocumentDB
},
properties: {
documentEndpoint: "",
tableEndpoint: "",
gremlinEndpoint: "",
cassandraEndpoint: ""
}
});
explorer.isAccountReady(true);
return explorer;
} }

View File

@@ -1,16 +0,0 @@
import Q from "q";
import * as DataModels from "../../Contracts/DataModels";
import { NotificationsClientBase } from "../../Common/NotificationsClientBase";
export class NotificationsClient extends NotificationsClientBase {
private static readonly _notificationsApiSuffix: string = "/api/notifications";
public constructor() {
super(NotificationsClient._notificationsApiSuffix);
}
public fetchNotifications(): Q.Promise<DataModels.Notification[]> {
// no notifications for the emulator
return Q([]);
}
}

View File

@@ -1,14 +1,8 @@
import Explorer from "../../Explorer/Explorer"; import Explorer from "../../Explorer/Explorer";
import { NotificationsClient } from "./NotificationsClient";
export default class HostedExplorerFactory { export default class HostedExplorerFactory {
public createExplorer(): Explorer { public createExplorer(): Explorer {
const explorer = new Explorer({ return new Explorer();
notificationsClient: new NotificationsClient(),
isEmulator: false
});
return explorer;
} }
public static reInitializeDocumentClientUtilityForExplorer(explorer: Explorer): void { public static reInitializeDocumentClientUtilityForExplorer(explorer: Explorer): void {

View File

@@ -1,9 +0,0 @@
import { NotificationsClientBase } from "../../Common/NotificationsClientBase";
export class NotificationsClient extends NotificationsClientBase {
private static readonly _notificationsApiSuffix: string = "/api/guest/notifications";
public constructor() {
super(NotificationsClient._notificationsApiSuffix);
}
}

View File

@@ -1,13 +0,0 @@
import Explorer from "../../Explorer/Explorer";
import { NotificationsClient } from "./NotificationsClient";
export default class PortalExplorerFactory {
public createExplorer(): Explorer {
var explorer = new Explorer({
notificationsClient: new NotificationsClient(),
isEmulator: false
});
return explorer;
}
}

View File

@@ -1,10 +1,8 @@
import PortalExplorerFactory from "./ExplorerFactory";
import "../../Explorer/Tables/DataTable/DataTableBindingManager"; import "../../Explorer/Tables/DataTable/DataTableBindingManager";
import Explorer from "../../Explorer/Explorer"; import Explorer from "../../Explorer/Explorer";
export function initializeExplorer(): Explorer { export function initializeExplorer(): Explorer {
const portalExplorerFactory = new PortalExplorerFactory(); const explorer = new Explorer();
const explorer = portalExplorerFactory.createExplorer();
window.addEventListener("message", explorer.handleMessage.bind(explorer), false); window.addEventListener("message", explorer.handleMessage.bind(explorer), false);
return explorer; return explorer;

View File

@@ -1,9 +0,0 @@
import { NotificationsClientBase } from "../../Common/NotificationsClientBase";
export class NotificationsClient extends NotificationsClientBase {
private static readonly _notificationsApiSuffix: string = "/api/notifications";
public constructor() {
super(NotificationsClient._notificationsApiSuffix);
}
}

View File

@@ -9,10 +9,7 @@ describe("TabRouteHandler", () => {
let tabRouteHandler: TabRouteHandler; let tabRouteHandler: TabRouteHandler;
beforeAll(() => { beforeAll(() => {
(<any>window).dataExplorer = new Explorer({ (<any>window).dataExplorer = new Explorer(); // create a mock to avoid null refs
notificationsClient: null,
isEmulator: false
}); // create a mock to avoid null refs
}); });
beforeEach(() => { beforeEach(() => {

View File

@@ -8,7 +8,6 @@ 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"; import { userContext } from "../UserContext";
import { createUpdateCassandraKeyspace } from "../Utils/arm/generatedClients/2020-04-01/cassandraResources";
export class AddDbUtilities { export class AddDbUtilities {
// todo - remove any // todo - remove any
@@ -48,6 +47,7 @@ export class AddDbUtilities {
// todo - remove any // todo - remove any
public static async createCassandraKeyspace( public static async createCassandraKeyspace(
armEndpoint: string,
params: DataModels.RpParameters, params: DataModels.RpParameters,
rpOptions: DataModels.RpOptions rpOptions: DataModels.RpOptions
): Promise<any> { ): Promise<any> {
@@ -70,11 +70,9 @@ export class AddDbUtilities {
} }
try { try {
await createUpdateCassandraKeyspace( await AddDbUtilities.getRpClient<DataModels.CreateDatabaseWithRpResponse>(armEndpoint).putAsync(
userContext.subscriptionId, AddDbUtilities._getCassandraKeyspaceUri(params),
userContext.resourceGroup, DataExplorerConstants.ArmApiVersions.publicVersion,
userContext.databaseAccount?.name,
params.db,
rpPayloadToCreateKeyspace rpPayloadToCreateKeyspace
); );
} catch (reason) { } catch (reason) {
@@ -161,7 +159,10 @@ export class AddDbUtilities {
} }
private static _handleCreationError(reason: any, params: DataModels.RpParameters, dbType: string = "database") { private static _handleCreationError(reason: any, params: DataModels.RpParameters, dbType: string = "database") {
NotificationConsoleUtils.logConsoleError(`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`); NotificationConsoleUtils.logConsoleMessage(
ConsoleDataType.Error,
`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`
);
if (reason.status === HttpStatusCodes.Forbidden) { if (reason.status === HttpStatusCodes.Forbidden) {
sendMessage({ type: MessageTypes.ForbiddenError }); sendMessage({ type: MessageTypes.ForbiddenError });
return; return;

View File

@@ -60,7 +60,7 @@ describe("AuthorizationUtils", () => {
}); });
describe("displayTokenRenewalPromptForStatus()", () => { describe("displayTokenRenewalPromptForStatus()", () => {
let explorer = new Explorer({} as any) as jest.Mocked<Explorer>; let explorer = new Explorer() as jest.Mocked<Explorer>;
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PATCH", apiVersion, 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,7 +44,7 @@ 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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -55,7 +61,7 @@ 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: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, 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: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, 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. */
@@ -143,7 +149,7 @@ 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: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion, 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. */

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */

View File

@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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. */
@@ -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: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, 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 */

File diff suppressed because it is too large Load Diff

View File

@@ -1,79 +1,81 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"noEmit": true, "noEmit": true,
"strictNullChecks": true, "strictNullChecks": true,
"strict": true, "strict": true,
"noUnusedLocals": true "noUnusedLocals": true
}, },
"files": [ "files": [
"./src/AuthType.ts", "./src/AuthType.ts",
"./src/Bindings/BindingHandlersRegisterer.ts", "./src/Bindings/BindingHandlersRegisterer.ts",
"./src/Bindings/ReactBindingHandler.ts", "./src/Bindings/ReactBindingHandler.ts",
"./src/Common/ArrayHashMap.ts", "./src/Common/ArrayHashMap.ts",
"./src/Common/Constants.ts", "./src/Common/Constants.ts",
"./src/Common/DeleteFeedback.ts", "./src/Common/DeleteFeedback.ts",
"./src/Common/HashMap.ts", "./src/Common/HashMap.ts",
"./src/Common/HeadersUtility.ts", "./src/Common/HeadersUtility.ts",
"./src/Common/Logger.ts", "./src/Common/Logger.ts",
"./src/Common/MessageHandler.ts", "./src/Common/MessageHandler.ts",
"./src/Common/MongoUtility.ts", "./src/Common/MongoUtility.ts",
"./src/Common/ObjectCache.ts", "./src/Common/ObjectCache.ts",
"./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/ConfigContext.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",
"./src/Contracts/ExplorerContracts.ts", "./src/Contracts/ExplorerContracts.ts",
"./src/Contracts/Versions.ts", "./src/Contracts/Versions.ts",
"./src/Controls/Heatmap/Heatmap.ts", "./src/Controls/Heatmap/Heatmap.ts",
"./src/Controls/Heatmap/HeatmapDatatypes.ts", "./src/Controls/Heatmap/HeatmapDatatypes.ts",
"./src/Definitions/globals.d.ts", "./src/DefaultAccountExperienceType.ts",
"./src/Definitions/html.d.ts", "./src/Definitions/globals.d.ts",
"./src/Definitions/jquery-ui.d.ts", "./src/Definitions/html.d.ts",
"./src/Definitions/jquery.d.ts", "./src/Definitions/jquery-ui.d.ts",
"./src/Definitions/plotly.js-cartesian-dist.d-min.ts", "./src/Definitions/jquery.d.ts",
"./src/Definitions/svg.d.ts", "./src/Definitions/plotly.js-cartesian-dist.d-min.ts",
"./src/Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.ts", "./src/Definitions/svg.d.ts",
"./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts", "./src/Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.ts",
"./src/Explorer/Controls/SmartUi/InputUtils.ts", "./src/Explorer/Controls/GitHub/GitHubStyleConstants.ts",
"./src/Explorer/Notebook/FileSystemUtil.ts", "./src/Explorer/Controls/SmartUi/InputUtils.ts",
"./src/Explorer/Notebook/NTeractUtil.ts", "./src/Explorer/Notebook/FileSystemUtil.ts",
"./src/Explorer/Notebook/NotebookComponent/actions.ts", "./src/Explorer/Notebook/NTeractUtil.ts",
"./src/Explorer/Notebook/NotebookComponent/loadTransform.ts", "./src/Explorer/Notebook/NotebookComponent/actions.ts",
"./src/Explorer/Notebook/NotebookComponent/reducers.ts", "./src/Explorer/Notebook/NotebookComponent/loadTransform.ts",
"./src/Explorer/Notebook/NotebookComponent/types.ts", "./src/Explorer/Notebook/NotebookComponent/reducers.ts",
"./src/Explorer/Notebook/NotebookContentItem.ts", "./src/Explorer/Notebook/NotebookComponent/types.ts",
"./src/Explorer/Notebook/NotebookUtil.ts", "./src/Explorer/Notebook/NotebookContentItem.ts",
"./src/Explorer/Panes/PaneComponents.ts", "./src/Explorer/Notebook/NotebookUtil.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts", "./src/Explorer/Panes/PaneComponents.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts", "./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts",
"./src/Explorer/Tables/Constants.ts", "./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts",
"./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts", "./src/Explorer/Tables/Constants.ts",
"./src/Explorer/Tabs/TabComponents.ts", "./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts",
"./src/GitHub/GitHubConnector.ts", "./src/Explorer/Tabs/TabComponents.ts",
"./src/Index.ts", "./src/GitHub/GitHubConnector.ts",
"./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts", "./src/Index.ts",
"./src/PlatformType.ts", "./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts",
"./src/ReactDevTools.ts", "./src/PlatformType.ts",
"./src/ResourceProvider/IResourceProviderClient.ts", "./src/ReactDevTools.ts",
"./src/Shared/ExplorerSettings.ts", "./src/ResourceProvider/IResourceProviderClient.ts",
"./src/Shared/StorageUtility.ts", "./src/Shared/ExplorerSettings.ts",
"./src/Shared/StringUtility.ts", "./src/Shared/StorageUtility.ts",
"./src/Shared/Telemetry/TelemetryConstants.ts", "./src/Shared/StringUtility.ts",
"./src/Shared/Telemetry/TelemetryProcessor.ts", "./src/Shared/Telemetry/TelemetryConstants.ts",
"./src/Shared/appInsights.ts", "./src/Shared/Telemetry/TelemetryProcessor.ts",
"./src/UserContext.ts", "./src/Shared/appInsights.ts",
"./src/Utils/GitHubUtils.ts", "./src/UserContext.ts",
"./src/Utils/MessageValidation.ts", "./src/Utils/Base64Utils.ts",
"./src/Utils/OfferUtils.ts", "./src/Utils/GitHubUtils.ts",
"./src/Utils/StringUtils.ts", "./src/Utils/MessageValidation.ts",
"./src/Utils/arm/generatedClients/2020-04-01/types.ts", "./src/Utils/OfferUtils.ts",
"./src/quickstart.ts", "./src/Utils/StringUtils.ts",
"./src/setupTests.ts", "./src/Utils/arm/generatedClients/2020-04-01/types.ts",
"./src/workers/upload/definitions.ts" "./src/quickstart.ts",
], "./src/setupTests.ts",
"include": [] "./src/workers/upload/definitions.ts"
],
"include": []
} }

View File

@@ -102,31 +102,31 @@ interface Property {
}[]; }[];
} }
const propertyToType = (property: Property, prop: string, required: boolean) => { const propertyToType = (property: Property, prop: string) => {
if (property) { if (property) {
if (property.allOf) { if (property.allOf) {
outputTypes.push(` outputTypes.push(`
/* ${property.description || "undocumented"} */ /* ${property.description || "undocumented"} */
${property.readOnly ? "readonly " : ""}${prop}${ ${property.readOnly ? "readonly " : ""}${prop}: ${property.allOf
required ? "" : "?" .map((allof: { $ref: string }) => refToType(allof.$ref))
}: ${property.allOf.map((allof: { $ref: string }) => refToType(allof.$ref)).join(" & ")}`); .join(" & ")}`);
} else if (property.$ref) { } else if (property.$ref) {
const type = refToType(property.$ref); const type = refToType(property.$ref);
outputTypes.push(` outputTypes.push(`
/* ${property.description || "undocumented"} */ /* ${property.description || "undocumented"} */
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type} ${property.readOnly ? "readonly " : ""}${prop}: ${type}
`); `);
} else if (property.type === "array") { } else if (property.type === "array") {
const type = refToType(property.items.$ref); const type = refToType(property.items.$ref);
outputTypes.push(` outputTypes.push(`
/* ${property.description || "undocumented"} */ /* ${property.description || "undocumented"} */
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type}[] ${property.readOnly ? "readonly " : ""}${prop}: ${type}[]
`); `);
} else if (property.type === "object") { } else if (property.type === "object") {
const type = refToType(property.$ref); const type = refToType(property.$ref);
outputTypes.push(` outputTypes.push(`
/* ${property.description || "undocumented"} */ /* ${property.description || "undocumented"} */
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${type} ${property.readOnly ? "readonly " : ""}${prop}: ${type}
`); `);
} else { } else {
if (property.type === undefined) { if (property.type === undefined) {
@@ -135,7 +135,7 @@ const propertyToType = (property: Property, prop: string, required: boolean) =>
} }
outputTypes.push(` outputTypes.push(`
/* ${property.description || "undocumented"} */ /* ${property.description || "undocumented"} */
${property.readOnly ? "readonly " : ""}${prop}${required ? "" : "?"}: ${ ${property.readOnly ? "readonly " : ""}${prop}: ${
propertyMap[property.type] ? propertyMap[property.type] : property.type propertyMap[property.type] ? propertyMap[property.type] : property.type
}`); }`);
} }
@@ -166,7 +166,7 @@ async function main() {
} }
for (const prop in schema.definitions[definition].properties) { for (const prop in schema.definitions[definition].properties) {
const property = schema.definitions[definition].properties[prop]; const property = schema.definitions[definition].properties[prop];
propertyToType(property, prop, schema.definitions[definition].required?.includes(prop)); propertyToType(property, prop);
} }
outputTypes.push(`}`); outputTypes.push(`}`);
outputTypes.push("\n\n"); outputTypes.push("\n\n");
@@ -245,7 +245,7 @@ async function main() {
) : Promise<${responseType(operation, "Types")}> { ) : Promise<${responseType(operation, "Types")}> {
const path = \`${path.replace(/{/g, "${")}\` const path = \`${path.replace(/{/g, "${")}\`
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${ return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "${method.toLocaleUpperCase()}", apiVersion, ${
bodyParameter ? "body" : "" bodyParameter ? "body: JSON.stringify(body)" : ""
} }) } })
} }
`); `);