in source/services/api/admin/lib/admin.js [429:465]
async modifyAuthorization(apiKeyId, applicationId, enabled) {
try {
const docClient = new AWS.DynamoDB.DocumentClient(this.config);
const updated_at = moment().utc().format();
const params = {
TableName: process.env.AUTHORIZATIONS_TABLE,
Key: {
api_key_id: apiKeyId,
application_id: applicationId
},
UpdateExpression: "set enabled = :enabled, updated_at = :updated_at",
ExpressionAttributeValues: {
":enabled": enabled,
":updated_at": updated_at
},
ReturnValues: 'ALL_NEW',
};
const response = await docClient.update(params).promise();
return Promise.resolve({
ApiKeyId: response.Attributes.api_key_id,
ApiKeyName: response.Attributes.api_key_name,
ApiKeyDescription: response.Attributes.api_key_description,
ApiKeyValue: response.Attributes.api_key_value,
ApplicationId: response.Attributes.application_id,
CreatedAt: response.Attributes.created_at,
UpdatedAt: response.Attributes.updated_at,
Enabled: response.Attributes.enabled
});
} catch (err) {
console.log(JSON.stringify(err));
return Promise.reject({
code: 500,
error: 'InternalFailure',
message: `Error modifying authorization`
});
}
}