From 864d9393f2d2561f87b026852e34980db1b02605 Mon Sep 17 00:00:00 2001 From: Garrett Ausfeldt Date: Thu, 25 Feb 2021 11:36:01 -0800 Subject: [PATCH] Change schema endpoints (#447) * fix resource bug (id is a method) * change schema endpoints * fix test Co-authored-by: REDMOND\gaausfel --- src/Explorer/Tree/Database.test.ts | 4 +++- src/Explorer/Tree/Database.ts | 4 +++- src/Juno/JunoClient.ts | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Explorer/Tree/Database.test.ts b/src/Explorer/Tree/Database.test.ts index b41e5a3d0..c37e0be94 100644 --- a/src/Explorer/Tree/Database.test.ts +++ b/src/Explorer/Tree/Database.test.ts @@ -69,11 +69,13 @@ describe("Add Schema", () => { subscriptionId: userContext.subscriptionId, resourceGroup: userContext.resourceGroup, accountName: userContext.databaseAccount.name, - resource: `dbs/${database.id}/colls/${collection.id}`, + resource: `dbs/${database.id()}/colls/${collection.id}`, status: "new", }); expect(checkForSchema).not.toBeNull(); expect(database.junoClient.getSchema).toBeCalledWith( + userContext.subscriptionId, + userContext.resourceGroup, userContext.databaseAccount.name, database.id(), collection.id diff --git a/src/Explorer/Tree/Database.ts b/src/Explorer/Tree/Database.ts index 431dc89fe..5534436e1 100644 --- a/src/Explorer/Tree/Database.ts +++ b/src/Explorer/Tree/Database.ts @@ -329,11 +329,13 @@ export default class Database implements ViewModels.Database { subscriptionId: userContext.subscriptionId, resourceGroup: userContext.resourceGroup, accountName: userContext.databaseAccount.name, - resource: `dbs/${this.id}/colls/${collection.id}`, + resource: `dbs/${this.id()}/colls/${collection.id}`, status: "new", }); checkForSchema = setInterval(async () => { const response: IJunoResponse = await this.junoClient.getSchema( + userContext.subscriptionId, + userContext.resourceGroup, userContext.databaseAccount.name, this.id(), collection.id diff --git a/src/Juno/JunoClient.ts b/src/Juno/JunoClient.ts index 561c7ac00..7c08fad4e 100644 --- a/src/Juno/JunoClient.ts +++ b/src/Juno/JunoClient.ts @@ -427,7 +427,7 @@ export class JunoClient { public async requestSchema( schemaRequest: DataModels.ISchemaRequest ): Promise> { - const response = await window.fetch(`${this.getAnalyticsUrl()}/${schemaRequest.accountName}/schema/request`, { + const response = await window.fetch(`${this.getAnalyticsUrl()}/schema/request`, { method: "POST", body: JSON.stringify(schemaRequest), headers: JunoClient.getHeaders(), @@ -445,12 +445,14 @@ export class JunoClient { } public async getSchema( + subscriptionId: string, + resourceGroup: string, accountName: string, databaseName: string, containerName: string ): Promise> { const response = await window.fetch( - `${this.getAnalyticsUrl()}/${accountName}/schema/${databaseName}/${containerName}`, + `${this.getAnalyticsUrl()}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/databaseAccounts/${accountName}/schema/${databaseName}/${containerName}`, { method: "GET", headers: JunoClient.getHeaders(),