in core/routemgmt/common/apigw-utils.js [247:285]
function deleteApiFromGateway(gwInfo, spaceGuid, apiId) {
var options = {
followAllRedirects: true,
url: gwInfo.gwUrl+'/'+encodeURIComponent(spaceGuid)+'/apis/'+encodeURIComponent(apiId),
agentOptions: {rejectUnauthorized: false},
headers: {
'Accept': 'application/json',
'User-Agent': UserAgent
}
};
if (gwInfo.gwAuth) {
options.headers.Authorization = 'Bearer ' + gwInfo.gwAuth;
}
console.log('deleteApiFromGateway: request: '+JSON.stringify(options));
return new Promise(function(resolve, reject) {
request.delete(options, function(error, response, body) {
var statusCode = response ? response.statusCode : undefined;
console.log('deleteApiFromGateway: response status:'+ statusCode);
if (error) console.error('Warning: deleteGatewayApi request failed: '+ makeJsonString(error));
if (body) console.log('deleteApiFromGateway: response body: '+makeJsonString(body));
if (response && response.headers) console.log('deleteApiFromGateway: response headers: '+makeJsonString(response.headers));
if (error) {
console.error('deleteApiFromGateway: Unable to delete the API Gateway');
reject('Unable to delete the API Gateway: '+makeJsonString(error));
} else if (statusCode != 200 && statusCode != 204) {
if (body) {
var errMsg = makeJsonString(body);
if (body.error && body.error.message) errMsg = body.error.message;
reject('Unable to delete the API Gateway (status code '+statusCode+'): '+ errMsg);
} else {
reject('Unable to delete the API Gateway: Response failure code: '+statusCode);
}
} else {
resolve();
}
});
});
}