Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async deleteStoreByAccessKey({ accessKey }: { accessKey: string }) {
try {
const storeId = await this.getStoreByAccessKey({ accessKey })
await got.delete(`http://${this.host}/stores/${storeId}`, {
...this.gotCommonOpts,
headers: {
'ERN-BUNDLE-STORE-ACCESS-KEY': accessKey,
},
})
return storeId
} catch (err) {
throw new Error(err.response?.text ?? err.message)
}
}
public async removeBinary(
descriptor: AppVersionDescriptor,
{
flavor,
}: {
flavor?: string
} = {}
): Promise {
await this.throwIfNoBinaryExistForDescriptor(descriptor, { flavor })
try {
await got.delete(this.urlToBinary(descriptor, { flavor }), {
...this.gotCommonOpts,
})
} catch (err) {
throw new Error(err.response?.text ?? err.message)
}
}
static async deleteUserSession({ sessionId }) {
const body = await got.delete(`${USERS_SERVICE_URI}/sessions/${sessionId}`).json();
return body;
}
function stop () {
startup.remove('stop-server')
got.delete('localhost:' + 5709)
}
async function deleteConcept(type, identifier, provider, headers) {
const url = `${getUrl('ingest', provider)}${type}/${identifier}`;
log.info(`deleteConcept ${url}`);
let result;
try {
result = await got.delete(url, {
headers
});
} catch (error) {
result = error.response;
}
const xmlObject = await parseXMLString(result.body);
let errorMessage;
if (result.statusCode !== 200) {
errorMessage = `Failed to delete, statusCode: ${result.statusCode}, statusMessage: ${result.statusMessage}`;
if (xmlObject.errors) {
errorMessage = `${errorMessage}, CMR error message: ${JSON.stringify(xmlObject.errors.error)}`;
}
log.info(errorMessage);
}
const del = exports.del = (path: string) => {
return got.delete(`${BASE_URI}${path}`, {
headers
});
};
query: query,
headers: {
Authorization: tokenRes.token_type + ' ' + tokenRes.access_token
},
body: JSON.stringify({
request: 'lineitems'
})
});
lineitemRes = JSON.parse(lineitemRes.body);
let success = true;
for (const lineitem of lineitemRes) {
try {
const lineitemUrl = lineitem.id;
provGradeServiceDebug('Deleting: ' + lineitemUrl);
await got.delete(lineitemUrl, {
headers: {
Authorization: tokenRes.token_type + ' ' + tokenRes.access_token
},
body: JSON.stringify({
request: 'lineitems'
})
});
provGradeServiceDebug('LineItem sucessfully deleted');
} catch (err) {
provGradeServiceDebug(err.message);
if ((0, _classPrivateFieldGet2.default)(this, _logger)) (0, _classPrivateFieldGet2.default)(this, _logger).log({
level: 'error',
message: 'Message: ' + err.message + '\nStack: ' + err.stack
});
success = false;
continue;
if (filters.resourceLinkId) queryParams.push(['resource_link_id', idtoken.platformContext.resource.id])
if (filters.limit) queryParams.push(['limit', filters.limit])
if (filters.tag) queryParams.push(['tag', filters.tag])
if (filters.resourceId) queryParams.push(['resource_id', filters.resourceId])
query = new URLSearchParams(queryParams)
}
let lineitemRes = await got.get(lineitemsEndpoint, { query: query, headers: { Authorization: tokenRes.token_type + ' ' + tokenRes.access_token }, body: JSON.stringify({ request: 'lineitems' }) })
lineitemRes = JSON.parse(lineitemRes.body)
let success = true
for (const lineitem of lineitemRes) {
try {
const lineitemUrl = lineitem.id
provGradeServiceDebug('Deleting: ' + lineitemUrl)
await got.delete(lineitemUrl, { headers: { Authorization: tokenRes.token_type + ' ' + tokenRes.access_token }, body: JSON.stringify({ request: 'lineitems' }) })
provGradeServiceDebug('LineItem sucessfully deleted')
} catch (err) {
provGradeServiceDebug(err.message)
if (this.#logger) this.#logger.log({ level: 'error', message: 'Message: ' + err.message + '\nStack: ' + err.stack })
success = false
continue
}
}
return success
} catch (err) {
provGradeServiceDebug(err.message)
if (this.#logger) this.#logger.log({ level: 'error', message: 'Message: ' + err.message + '\nStack: ' + err.stack })
return false
}
}
unlink(idParent, callback) {
let retval = {
success: false,
data: {},
};
Logger.verbose('Requesting nodes:children:delete endpoint (unlink)');
Logger.debug(`HTTP Request: DELETE '${account.metadataUrl}nodes/${idParent}/children/${this.getId()}'`);
got.delete(`${account.metadataUrl}nodes/${idParent}/children/${this.getId()}`, {
headers: {
Authorization: `Bearer ${account.token.access_token}`,
},
})
.then(response => {
Logger.debug(`Response returned with status code ${response.statusCode}.`);
Logger.silly(`Response body: ${response.body}`);
retval.data = JSON.parse(response.body);
if (response.statusCode === 200) {
retval.success = true;
this.replace(retval.data);
return this.save(() => {
return callback(null, retval);
});