mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Shell: Integrate Cloudshell to existing shells (#2098)
* first draft * refactored code * ux fix * add custom header support and fix ui * minor changes * hide last command also * remove logger * bug fixes * updated loick file * fix tests * moved files * update readme * documentation update * fix compilationerror * undefined check handle * format fix * format fix * fix lints * format fix * fix unrelatred test * code refator * fix format * ut fix * cgmanifest * Revert "cgmanifest" This reverts commit 2e76a6926ee0d3d4e0510f2e04e03446c2ca8c47. * fix snap * test fix * formatting code * updated xterm * include username in command * cloudshell add exit * fix test * format fix * tets fix * fix multiple open cloudshell calls * socket time out after 20 min * remove unused code * 120 min * Addressed comments
This commit is contained in:
@@ -47,6 +47,7 @@ interface Options {
|
||||
body?: unknown;
|
||||
queryParams?: ARMQueryParams;
|
||||
contentType?: string;
|
||||
customHeaders?: Record<string, string>;
|
||||
}
|
||||
|
||||
export async function armRequestWithoutPolling<T>({
|
||||
@@ -57,6 +58,7 @@ export async function armRequestWithoutPolling<T>({
|
||||
body: requestBody,
|
||||
queryParams,
|
||||
contentType,
|
||||
customHeaders,
|
||||
}: Options): Promise<{ result: T; operationStatusUrl: string }> {
|
||||
const url = new URL(path, host);
|
||||
url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion);
|
||||
@@ -65,18 +67,22 @@ export async function armRequestWithoutPolling<T>({
|
||||
queryParams.metricNames && url.searchParams.append("metricnames", queryParams.metricNames);
|
||||
}
|
||||
|
||||
if (!userContext.authorizationToken) {
|
||||
if (!userContext?.authorizationToken && !customHeaders?.["Authorization"]) {
|
||||
throw new Error("No authority token provided");
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
Authorization: userContext.authorizationToken || customHeaders?.["Authorization"] || "",
|
||||
[HttpHeaders.contentType]: contentType || "application/json",
|
||||
...(customHeaders || {}),
|
||||
};
|
||||
|
||||
const response = await window.fetch(url.href, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: userContext.authorizationToken,
|
||||
[HttpHeaders.contentType]: contentType || "application/json",
|
||||
},
|
||||
headers,
|
||||
body: requestBody ? JSON.stringify(requestBody) : undefined,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
let error: ARMError;
|
||||
try {
|
||||
@@ -109,6 +115,7 @@ export async function armRequest<T>({
|
||||
body: requestBody,
|
||||
queryParams,
|
||||
contentType,
|
||||
customHeaders,
|
||||
}: Options): Promise<T> {
|
||||
const armRequestResult = await armRequestWithoutPolling<T>({
|
||||
host,
|
||||
@@ -118,6 +125,7 @@ export async function armRequest<T>({
|
||||
body: requestBody,
|
||||
queryParams,
|
||||
contentType,
|
||||
customHeaders,
|
||||
});
|
||||
const operationStatusUrl = armRequestResult.operationStatusUrl;
|
||||
if (operationStatusUrl) {
|
||||
|
||||
Reference in New Issue
Block a user