From b168f5d781672e75d7240c3caf71f7e2dfc36dbe Mon Sep 17 00:00:00 2001 From: Adam Kowalski Date: Thu, 29 Jul 2021 11:39:17 -0500 Subject: [PATCH] feat(api): add Argo Tunnels endpoints --- index.js | 1 + lib/resources/ArgoTunnels.js | 90 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 lib/resources/ArgoTunnels.js diff --git a/index.js b/index.js index 8445953..3b776b6 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ const proxy = require('./lib/proxy'); /* eslint-disable global-require */ const resources = { + argoTunnels: require('./lib/resources/ArgoTunnels'), dnsRecords: require('./lib/resources/DNSRecords'), enterpriseZoneWorkersScripts: require('./lib/resources/EnterpriseZoneWorkersScripts'), enterpriseZoneWorkersRoutes: require('./lib/resources/EnterpriseZoneWorkersRoutes'), diff --git a/lib/resources/ArgoTunnels.js b/lib/resources/ArgoTunnels.js new file mode 100644 index 0000000..d53b91d --- /dev/null +++ b/lib/resources/ArgoTunnels.js @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2014-present Cloudflare, Inc. + + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +'use strict'; + +const prototypal = require('es-class'); +const auto = require('autocreate'); + +const Resource = require('../Resource'); +const method = require('../method'); + +/** + * Argo Tunnels represents the /accounts/:accountId/tunnels API endpoint. + * + * @class ArgoTunnels + * @hideconstructor + * @extends Resource + */ +module.exports = auto( + prototypal({ + extends: Resource, + path: 'accounts/:accountId/tunnels', + + includeBasic: ['browse', 'read', 'add', 'del'], + + /** + * clean removes stale connection resources from an Argo Tunnel + * + * @function clean + * @memberof ArgoTunnels + * @instance + * @async + * @param {string} accountId - The account ID + * @param {string} id - The tunnel ID being modified + * @returns {Promise} The response object. + */ + clean: method({ + method: 'DELETE', + path: ':id/connections', + }), + + /** + * browse allows for listing all Argo Tunnels for an account + * + * @function browse + * @memberof ArgoTunnels + * @instance + * @async + * @param {string} accountId - The account ID + * @returns {Promise} The Argo Tunnels response object. + */ + /** + * read allows for retrieving the specified Argo Tunnel + * + * @function read + * @memberof ArgoTunnels + * @instance + * @async + * @param {string} accountId - The account ID + * @param {string} id - The Argo Tunnel ID + * @returns {Promise} The Argo Tunnel object. + */ + /** + * add allows for creating a new Argo Tunnel for an account. + * + * @function add + * @memberof ArgoTunnels + * @instance + * @async + * @param {string} accountId - The account ID + * @param {Object} tunnel - The new Argo Tunnel object + * @returns {Promise} The created Argo Tunnel object. + */ + /** + * del allows for deleting the specified Tunnel + * + * @function del + * @memberof ArgoTunnels + * @instance + * @async + * @param {string} accountId - The account ID + * @param {string} id - The Argo Tunnel ID + * @returns {Promise} The deleted Argo Tunnel object. + */ + }) +);