From 69cc2edd74ccfde8fff0124458afe39c6f5ea45e Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 1 Sep 2020 13:39:42 -0400 Subject: [PATCH] resolves issue #370 resolves issue #370 --- src/api/server.js | 42 +++++++++++++++++++++++++++++++++++++++++ src/index.js | 4 +++- test/api/server.test.js | 6 ++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/api/server.js b/src/api/server.js index d9989a24..0296de0f 100644 --- a/src/api/server.js +++ b/src/api/server.js @@ -1133,3 +1133,45 @@ exports.deleteReverseIPv6 = { } } } + +/** + * Enables DDoS Protection for a server.
+ * {@link https://www.vultr.com/api/#server_ddos_protection_enable} + * @function enableDDoSProtection + * @memberof server + * @instance + * @param {object} parameters + * @param {number} parameters.SUBID - Unique identifier of a subscription. + */ +exports.enableDDoSProtection = { + url: '/server/ddos_protection_enable', + requestType: 'POST', + apiKeyRequired: true, + parameters: { + SUBID: { + type: 'number', + required: true + } + } +} + +/** + * Disables DDoS Protection for a server.
+ * {@link https://www.vultr.com/api/#server_ddos_protection_disable} + * @function disableDDoSProtection + * @memberof server + * @instance + * @param {object} parameters + * @param {number} parameters.SUBID - Unique identifier of a subscription. + */ +exports.disableDDoSProtection = { + url: '/server/ddos_protection_disable', + requestType: 'POST', + apiKeyRequired: true, + parameters: { + SUBID: { + type: 'number', + required: true + } + } +} diff --git a/src/index.js b/src/index.js index f1425f01..53c14bd8 100644 --- a/src/index.js +++ b/src/index.js @@ -274,7 +274,9 @@ exports.initialize = config => { setDefaultReverseIPv4: createRequestFunction( server.setDefaultReverseIPv4 ), - deleteReverseIPv6: createRequestFunction(server.deleteReverseIPv6) + deleteReverseIPv6: createRequestFunction(server.deleteReverseIPv6), + enableDDoSProtection: createRequestFunction(server.enableDDoSProtection), + disableDDoSProtection: createRequestFunction(server.disableDDoSProtection) }, snapshot: { create: createRequestFunction(snapshot.create), diff --git a/test/api/server.test.js b/test/api/server.test.js index 5b22c7c0..416a20be 100644 --- a/test/api/server.test.js +++ b/test/api/server.test.js @@ -321,6 +321,12 @@ const mockParameters = { deleteReverseIPv6: { SUBID: 1312965, ip: '192.0.2.1' + }, + enableDDoSProtection: { + SUBID: 1312965 + }, + disableDDoSProtection: { + SUBID: 1312965 } }