mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-29 00:47:01 +00:00
Use SDK calls to read and update shared throughput for Tables API (#278)
RP does not supporting reading or updating database level throughput for Tables API so we have to switch back to using SDK calls for these operations.
This commit is contained in:
parent
d525afa142
commit
9933a4988a
@ -17,14 +17,12 @@ import { userContext } from "../../UserContext";
|
|||||||
export const readDatabaseOffer = async (
|
export const readDatabaseOffer = async (
|
||||||
params: DataModels.ReadDatabaseOfferParams
|
params: DataModels.ReadDatabaseOfferParams
|
||||||
): Promise<DataModels.OfferWithHeaders> => {
|
): Promise<DataModels.OfferWithHeaders> => {
|
||||||
if (userContext.defaultExperience === DefaultAccountExperienceType.Table) {
|
|
||||||
throw new Error("Reading database offer is not allowed for tables accounts");
|
|
||||||
}
|
|
||||||
|
|
||||||
const clearMessage = logConsoleProgress(`Querying offer for database ${params.databaseId}`);
|
const clearMessage = logConsoleProgress(`Querying offer for database ${params.databaseId}`);
|
||||||
let offerId = params.offerId;
|
let offerId = params.offerId;
|
||||||
if (!offerId) {
|
if (!offerId) {
|
||||||
offerId = await (window.authType === AuthType.AAD && !userContext.useSDKOperations
|
offerId = await (window.authType === AuthType.AAD &&
|
||||||
|
!userContext.useSDKOperations &&
|
||||||
|
userContext.defaultExperience !== DefaultAccountExperienceType.Table
|
||||||
? getDatabaseOfferIdWithARM(params.databaseId)
|
? getDatabaseOfferIdWithARM(params.databaseId)
|
||||||
: getDatabaseOfferIdWithSDK(params.databaseResourceId));
|
: getDatabaseOfferIdWithSDK(params.databaseResourceId));
|
||||||
if (!offerId) {
|
if (!offerId) {
|
||||||
|
@ -60,9 +60,14 @@ export const updateOffer = async (params: UpdateOfferParams): Promise<Offer> =>
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (window.authType === AuthType.AAD && !userContext.useSDKOperations) {
|
if (window.authType === AuthType.AAD && !userContext.useSDKOperations) {
|
||||||
updatedOffer = await (params.collectionId
|
if (params.collectionId) {
|
||||||
? updateCollectionOfferWithARM(params)
|
updatedOffer = await updateCollectionOfferWithARM(params);
|
||||||
: updateDatabaseOfferWithARM(params));
|
} else if (userContext.defaultExperience === DefaultAccountExperienceType.Table) {
|
||||||
|
// update table's database offer with SDK since RP doesn't support it
|
||||||
|
updatedOffer = await updateOfferWithSDK(params);
|
||||||
|
} else {
|
||||||
|
updatedOffer = await updateDatabaseOfferWithARM(params);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
updatedOffer = await updateOfferWithSDK(params);
|
updatedOffer = await updateOfferWithSDK(params);
|
||||||
}
|
}
|
||||||
@ -115,10 +120,6 @@ const updateCollectionOfferWithARM = async (params: UpdateOfferParams): Promise<
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateDatabaseOfferWithARM = async (params: UpdateOfferParams): Promise<Offer> => {
|
const updateDatabaseOfferWithARM = async (params: UpdateOfferParams): Promise<Offer> => {
|
||||||
if (userContext.defaultExperience === DefaultAccountExperienceType.Table) {
|
|
||||||
throw new Error("Updating database offer is not allowed for tables accounts");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (userContext.defaultExperience) {
|
switch (userContext.defaultExperience) {
|
||||||
case DefaultAccountExperienceType.DocumentDB:
|
case DefaultAccountExperienceType.DocumentDB:
|
||||||
|
@ -201,11 +201,7 @@ export default class Database implements ViewModels.Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async loadOffer(): Promise<void> {
|
public async loadOffer(): Promise<void> {
|
||||||
if (
|
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
||||||
!this.container.isServerlessEnabled() &&
|
|
||||||
this.container.defaultExperience() !== DefaultAccountExperienceType.Table &&
|
|
||||||
!this.offer()
|
|
||||||
) {
|
|
||||||
const params: DataModels.ReadDatabaseOfferParams = {
|
const params: DataModels.ReadDatabaseOfferParams = {
|
||||||
databaseId: this.id(),
|
databaseId: this.id(),
|
||||||
databaseResourceId: this.self
|
databaseResourceId: this.self
|
||||||
|
Loading…
Reference in New Issue
Block a user