@dynatrace-sdk/client-app-engine-registry
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -5,2 +5,8 @@ # AppEngine - Registry | ||
## 1.5.2 | ||
### Patch Changes | ||
- Fixed a bug that caused internal http-client errors to be thrown for error responses. | ||
## 1.5.1 | ||
@@ -7,0 +13,0 @@ |
428
cjs/index.js
@@ -111,7 +111,8 @@ /** | ||
var ApiClientError = class extends Error { | ||
errorType = "JS Error" /* COMMON */; | ||
constructor(name, message) { | ||
constructor(name, message, cause) { | ||
super(message); | ||
this.cause = cause; | ||
this.name = name; | ||
} | ||
errorType = "JS Error" /* COMMON */; | ||
}; | ||
@@ -126,4 +127,4 @@ function isApiClientError(e) { | ||
response; | ||
constructor(name, response, body, message) { | ||
super(name, message); | ||
constructor(name, response, body, message, cause) { | ||
super(name, message, cause); | ||
this.errorType = "Http Error" /* HTTP */; | ||
@@ -157,2 +158,3 @@ this.body = body; | ||
body: error.body, | ||
cause: error.cause, | ||
...getOptionalErrorRef(error.body) | ||
@@ -165,3 +167,4 @@ }; | ||
stack: error.stack, | ||
type: "JS Error" /* COMMON */ | ||
type: "JS Error" /* COMMON */, | ||
cause: error.cause | ||
}; | ||
@@ -185,11 +188,19 @@ } | ||
// packages/client/app-engine-registry/src/lib/error-envelopes/get-error-message.ts | ||
function serializeData(data) { | ||
try { | ||
return JSON.stringify(data); | ||
} catch (e) { | ||
return String(data); | ||
} | ||
} | ||
function getMessagesFromErrorDetails(details) { | ||
const messages = []; | ||
Object.entries(details).forEach(([name, data]) => { | ||
const serializedData = serializeData(data); | ||
switch (name) { | ||
case "missingScopes": | ||
messages.push(`Missing scopes: ${data}`); | ||
messages.push(`Missing scopes: ${serializedData}`); | ||
break; | ||
default: | ||
messages.push(`${name}: ${data}`); | ||
messages.push(`${name}: ${serializedData}`); | ||
} | ||
@@ -921,20 +932,41 @@ }, []); | ||
}); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson18(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApps:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson18(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApps:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -944,61 +976,67 @@ } | ||
async installApp(config) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps`, | ||
method: "POST", | ||
requestBodyType: "binary", | ||
body: config.body, | ||
headers: { | ||
"Content-Type": "application/zip", | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
if (200 <= status && status < 300) { | ||
return true; | ||
try { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps`, | ||
method: "POST", | ||
requestBodyType: "binary", | ||
body: config.body, | ||
headers: { | ||
"Content-Type": "application/zip", | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [202].includes(status); | ||
} | ||
return [400].includes(status); | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson20(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:202`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
}); | ||
switch (response.status) { | ||
case 400: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
const errorBody = fromJson26(responseValue); | ||
throw new ErrorEnvelopeError("400", response, errorBody, getErrorMessage(errorBody, "Bad Request")); | ||
} catch (err) { | ||
if (err instanceof ErrorEnvelopeError) { | ||
throw err; | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
switch (response.status) { | ||
case 400: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
const errorBody = fromJson26(responseValue); | ||
throw new ErrorEnvelopeError("400", response, errorBody, getErrorMessage(errorBody, "Bad Request"), e); | ||
} catch (err) { | ||
if (err instanceof ErrorEnvelopeError) { | ||
throw err; | ||
} | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:400`, | ||
err, | ||
responseValue, | ||
"ErrorEnvelope", | ||
void 0 | ||
); | ||
} | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:400`, | ||
err, | ||
responseValue, | ||
"ErrorEnvelope", | ||
void 0 | ||
); | ||
} | ||
} | ||
case 202: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson20(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:${response.status}`, | ||
err, | ||
default: { | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
} | ||
} | ||
default: { | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`) | ||
); | ||
} | ||
} | ||
@@ -1011,20 +1049,41 @@ } | ||
const query = toQueryString({ query: config.query }); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps:search-actions${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson29(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.searchActions:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps:search-actions${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson29(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.searchActions:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1038,20 +1097,41 @@ } | ||
const query = toQueryString({ "add-fields": config.addFields }); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson17(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApp:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson17(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApp:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1061,8 +1141,26 @@ } | ||
async uninstallApp(config) { | ||
await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}`, | ||
method: "DELETE", | ||
abortSignal: config.abortSignal | ||
}); | ||
return; | ||
try { | ||
await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}`, | ||
method: "DELETE", | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [202].includes(status); | ||
} | ||
}); | ||
return; | ||
} catch (e) { | ||
if (!(0, import_http_client.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
} | ||
} | ||
@@ -1148,20 +1246,41 @@ }; | ||
async getAppManifestSchema(abortSignal) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.manifest.schema.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return responseValue; | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getAppManifestSchema:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.manifest.schema.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return responseValue; | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getAppManifestSchema:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client2.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1171,20 +1290,41 @@ } | ||
async getDefaultCspProperties(abortSignal) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.default.csp.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson31(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getDefaultCspProperties:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.default.csp.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson31(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getDefaultCspProperties:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!(0, import_http_client2.isHttpClientResponseError)(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1191,0 +1331,0 @@ } |
@@ -35,3 +35,3 @@ --- | ||
<div class="col" style={{textAlign: 'right'}}> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/client-app-engine-registry/v/1.5.1">v1.5.1</a> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/client-app-engine-registry/v/1.5.2">v1.5.2</a> | ||
</div> | ||
@@ -38,0 +38,0 @@ </div> |
{ | ||
"dynagen": { | ||
"version": "0.12.5", | ||
"version": "0.12.9", | ||
"generatedAt": "", | ||
"template": { | ||
"name": "@dynatrace-sdk/template-typescript-client", | ||
"version": "0.17.13" | ||
"version": "0.18.5" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
438
esm/index.js
@@ -23,3 +23,6 @@ /** | ||
// packages/client/app-engine-registry/src/lib/apis/app-engine-registry-apps-api.ts | ||
import { httpClient as defaultHttpClient } from "@dynatrace-sdk/http-client"; | ||
import { | ||
httpClient as defaultHttpClient, | ||
isHttpClientResponseError | ||
} from "@dynatrace-sdk/http-client"; | ||
@@ -47,7 +50,8 @@ // packages/platform/shared/utils/get-global-with-dt-runtime.ts | ||
var ApiClientError = class extends Error { | ||
errorType = "JS Error" /* COMMON */; | ||
constructor(name, message) { | ||
constructor(name, message, cause) { | ||
super(message); | ||
this.cause = cause; | ||
this.name = name; | ||
} | ||
errorType = "JS Error" /* COMMON */; | ||
}; | ||
@@ -62,4 +66,4 @@ function isApiClientError(e) { | ||
response; | ||
constructor(name, response, body, message) { | ||
super(name, message); | ||
constructor(name, response, body, message, cause) { | ||
super(name, message, cause); | ||
this.errorType = "Http Error" /* HTTP */; | ||
@@ -93,2 +97,3 @@ this.body = body; | ||
body: error.body, | ||
cause: error.cause, | ||
...getOptionalErrorRef(error.body) | ||
@@ -101,3 +106,4 @@ }; | ||
stack: error.stack, | ||
type: "JS Error" /* COMMON */ | ||
type: "JS Error" /* COMMON */, | ||
cause: error.cause | ||
}; | ||
@@ -121,11 +127,19 @@ } | ||
// packages/client/app-engine-registry/src/lib/error-envelopes/get-error-message.ts | ||
function serializeData(data) { | ||
try { | ||
return JSON.stringify(data); | ||
} catch (e) { | ||
return String(data); | ||
} | ||
} | ||
function getMessagesFromErrorDetails(details) { | ||
const messages = []; | ||
Object.entries(details).forEach(([name, data]) => { | ||
const serializedData = serializeData(data); | ||
switch (name) { | ||
case "missingScopes": | ||
messages.push(`Missing scopes: ${data}`); | ||
messages.push(`Missing scopes: ${serializedData}`); | ||
break; | ||
default: | ||
messages.push(`${name}: ${data}`); | ||
messages.push(`${name}: ${serializedData}`); | ||
} | ||
@@ -857,20 +871,41 @@ }, []); | ||
}); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson18(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApps:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson18(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApps:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -880,61 +915,67 @@ } | ||
async installApp(config) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps`, | ||
method: "POST", | ||
requestBodyType: "binary", | ||
body: config.body, | ||
headers: { | ||
"Content-Type": "application/zip", | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
if (200 <= status && status < 300) { | ||
return true; | ||
try { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps`, | ||
method: "POST", | ||
requestBodyType: "binary", | ||
body: config.body, | ||
headers: { | ||
"Content-Type": "application/zip", | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [202].includes(status); | ||
} | ||
return [400].includes(status); | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson20(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:202`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
}); | ||
switch (response.status) { | ||
case 400: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
const errorBody = fromJson26(responseValue); | ||
throw new ErrorEnvelopeError("400", response, errorBody, getErrorMessage(errorBody, "Bad Request")); | ||
} catch (err) { | ||
if (err instanceof ErrorEnvelopeError) { | ||
throw err; | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
switch (response.status) { | ||
case 400: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
const errorBody = fromJson26(responseValue); | ||
throw new ErrorEnvelopeError("400", response, errorBody, getErrorMessage(errorBody, "Bad Request"), e); | ||
} catch (err) { | ||
if (err instanceof ErrorEnvelopeError) { | ||
throw err; | ||
} | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:400`, | ||
err, | ||
responseValue, | ||
"ErrorEnvelope", | ||
void 0 | ||
); | ||
} | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:400`, | ||
err, | ||
responseValue, | ||
"ErrorEnvelope", | ||
void 0 | ||
); | ||
} | ||
} | ||
case 202: { | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson20(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.installApp:${response.status}`, | ||
err, | ||
default: { | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
} | ||
} | ||
default: { | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`) | ||
); | ||
} | ||
} | ||
@@ -947,20 +988,41 @@ } | ||
const query = toQueryString({ query: config.query }); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps:search-actions${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson29(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.searchActions:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps:search-actions${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson29(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.searchActions:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -974,20 +1036,41 @@ } | ||
const query = toQueryString({ "add-fields": config.addFields }); | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson17(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApp:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}${query}`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson17(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistryAppsClient.getApp:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -997,8 +1080,26 @@ } | ||
async uninstallApp(config) { | ||
await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}`, | ||
method: "DELETE", | ||
abortSignal: config.abortSignal | ||
}); | ||
return; | ||
try { | ||
await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/apps/${config.id}`, | ||
method: "DELETE", | ||
abortSignal: config.abortSignal, | ||
statusValidator: (status) => { | ||
return [202].includes(status); | ||
} | ||
}); | ||
return; | ||
} catch (e) { | ||
if (!isHttpClientResponseError(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
} | ||
} | ||
@@ -1009,3 +1110,6 @@ }; | ||
// packages/client/app-engine-registry/src/lib/apis/app-engine-registry-schema-manifest-api.ts | ||
import { httpClient as defaultHttpClient2 } from "@dynatrace-sdk/http-client"; | ||
import { | ||
httpClient as defaultHttpClient2, | ||
isHttpClientResponseError as isHttpClientResponseError2 | ||
} from "@dynatrace-sdk/http-client"; | ||
@@ -1085,20 +1189,41 @@ // packages/client/app-engine-registry/src/lib/models/app-default-csp.transformation.ts | ||
async getAppManifestSchema(abortSignal) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.manifest.schema.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return responseValue; | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getAppManifestSchema:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.manifest.schema.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return responseValue; | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getAppManifestSchema:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError2(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1108,20 +1233,41 @@ } | ||
async getDefaultCspProperties(abortSignal) { | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.default.csp.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson31(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getDefaultCspProperties:200`, | ||
err, | ||
const response = await this.httpClient.send({ | ||
url: `/platform/app-engine/registry/v1/app.default.csp.json`, | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json" | ||
}, | ||
abortSignal, | ||
statusValidator: (status) => { | ||
return [200].includes(status); | ||
} | ||
}); | ||
const responseValue = await response.body("json"); | ||
try { | ||
return fromJson31(responseValue); | ||
} catch (err) { | ||
throw new InvalidResponseError( | ||
`AppEngineRegistrySchemaManifestClient.getDefaultCspProperties:200`, | ||
err, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
); | ||
} | ||
} catch (e) { | ||
if (isInvalidResponseError(e)) { | ||
throw e; | ||
} | ||
if (!isHttpClientResponseError2(e)) { | ||
throw new ApiClientError("UnexpectedError", "Unexpected error", e); | ||
} | ||
const response = e.response; | ||
const responseValue = await response.body("text").catch(() => ""); | ||
throw new ClientRequestError( | ||
`${response.status}`, | ||
response, | ||
responseValue, | ||
void 0, | ||
void 0 | ||
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`), | ||
e | ||
); | ||
@@ -1128,0 +1274,0 @@ } |
{ | ||
"name": "@dynatrace-sdk/client-app-engine-registry", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Manage Dynatrace AppEngine apps.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
# @dynatrace-sdk/client-app-engine-registry | ||
[![npm](https://img.shields.io/badge/npm-v1.5.1-blue)](https://www.npmjs.com/package/@dynatrace-sdk/client-app-engine-registry/v/1.5.1) | ||
[![npm](https://img.shields.io/badge/npm-v1.5.2-blue)](https://www.npmjs.com/package/@dynatrace-sdk/client-app-engine-registry/v/1.5.2) | ||
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
@@ -5,0 +5,0 @@ |
@@ -6,5 +6,6 @@ import { ErrorType } from '@dynatrace-sdk/error-handlers'; | ||
export declare class ApiClientError extends Error { | ||
readonly cause?: any; | ||
errorType: ErrorType; | ||
constructor(name: string, message?: string); | ||
constructor(name: string, message?: string, cause?: any); | ||
} | ||
export declare function isApiClientError(e: any): e is ApiClientError; |
@@ -6,4 +6,4 @@ import { HttpClientResponse } from '@dynatrace-sdk/http-client'; | ||
response: HttpClientResponse; | ||
constructor(name: string, response: HttpClientResponse, body: DTO, message?: string); | ||
constructor(name: string, response: HttpClientResponse, body: DTO, message?: string, cause?: any); | ||
} | ||
export declare function isClientRequestError<DTO>(e: any): e is ClientRequestError<DTO>; |
@@ -1,2 +0,2 @@ | ||
export { AbortController, AbortSignal, BaseError, Binary, BinaryFormDataRequestField, BinaryFormDataResponseField, DataTypeError, DataTypes, FormDataRequestBody, FormDataRequestField, FormDataResponseBody, FormDataResponseField, Headers, HttpClient, HttpClientAbortError, HttpClientNetworkError, HttpClientRequestError, HttpClientRequestOptions, HttpClientResponse, HttpClientResponseError, JsonFormDataRequestField, RequestBodyTypes, ResponseBodyTypes, StatusValidator, TextFormDataRequestField, TextFormDataResponseField, UnsupportedOperationError, } from './lib/types'; | ||
export { AbortController, AbortSignal, BaseError, Binary, BinaryFormDataRequestField, BinaryFormDataResponseField, DataTypeError, DataTypes, FormDataRequestBody, FormDataRequestField, FormDataResponseBody, FormDataResponseField, Headers, HttpClient, HttpClientAbortError, HttpClientNetworkError, HttpClientRequestError, HttpClientRequestOptions, HttpClientResponse, HttpClientResponseError, JsonFormDataRequestField, RequestBodyTypes, ResponseBodyTypes, StatusValidator, TextFormDataRequestField, TextFormDataResponseField, UnsupportedOperationError, isHttpClientResponseError, isHttpClientAbortError, isHttpClientNetworkError, isHttpClientRequestError, } from './lib/types'; | ||
export { AbortController as PlatformAbortController, AbortSignal as PlatformAbortSignal, BaseError as PlatformBaseError, Binary as PlatformBinary, DataTypeError as PlatformDataTypeError, HttpClient as PlatformHttpClient, HttpClientAbortError as PlatformHttpClientAbortError, HttpClientRequestError as PlatformHttpClientRequestError, HttpClientResponse as PlatformHttpClientResponse, HttpClientResponseError as PlatformHttpClientResponseError, UnsupportedOperationError as PlatformUnsupportedOperationError, httpClient, } from './lib/platform'; |
@@ -15,1 +15,2 @@ import { BaseError } from './base-error'; | ||
} | ||
export declare function isHttpClientAbortError(e: any): e is HttpClientAbortError; |
@@ -15,1 +15,2 @@ import { BaseError } from './base-error'; | ||
} | ||
export declare function isHttpClientNetworkError(e: any): e is HttpClientNetworkError; |
@@ -15,1 +15,2 @@ import { BaseError } from './base-error'; | ||
} | ||
export declare function isHttpClientRequestError(e: any): e is HttpClientRequestError; |
@@ -20,1 +20,2 @@ import { HttpClientResponse } from './http-client-response'; | ||
} | ||
export declare function isHttpClientResponseError(e: any): e is HttpClientResponseError; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203834
4248