├── .babelrc ├── .prettierrc.js ├── docs ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ └── OpenSans-LightItalic-webfont.woff ├── scripts │ ├── linenumber.js │ └── prettify │ │ └── lang-css.js ├── styles │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css ├── account.js.html ├── applications.js.html ├── operating-systems.js.html ├── plans.js.html ├── backups.js.html ├── regions.js.html ├── billing.js.html ├── iso.js.html ├── account.html ├── applications.html ├── operatingSystems.html ├── ssh-keys.js.html ├── vpcs.js.html ├── users.js.html ├── index.html ├── startup-scripts.js.html ├── snapshots.js.html ├── backup.html ├── plans.html └── regions.html ├── .husky ├── pre-push └── pre-commit ├── tsconfig.json ├── .github ├── dependabot.yml └── workflows │ ├── notify-pr.yml │ ├── notify-issue.yml │ ├── coverage.yml │ ├── codeql-analysis.yml │ └── release.yml ├── .codecov.yml ├── test ├── config.js ├── api │ ├── operating-systems.test.js │ ├── account.test.js │ ├── backups.test.js │ ├── applications.test.js │ ├── plans.test.js │ ├── ssh-keys.test.js │ ├── regions.test.js │ ├── vpcs.test.js │ ├── startup-scripts.test.js │ ├── iso.test.js │ ├── block-storage.test.js │ ├── snapshots.test.js │ ├── users.test.js │ ├── vpc2.test.js │ ├── billing.test.js │ ├── object-storage.test.js │ ├── reserved-ips.test.js │ ├── dns.test.js │ ├── firewall.test.js │ └── load-balancers.test.js ├── index.test.js └── util.js ├── .eslintrc.js ├── src ├── api │ ├── account.js │ ├── applications.js │ ├── operating-systems.js │ ├── plans.js │ ├── backups.js │ ├── regions.js │ ├── billing.js │ ├── iso.js │ ├── ssh-keys.js │ ├── vpcs.js │ ├── users.js │ ├── startup-scripts.js │ ├── snapshots.js │ ├── object-storage.js │ ├── block-storage.js │ ├── vpc2.js │ ├── reserved-ips.js │ └── firewall.js └── util.js ├── LICENSE.md ├── CONTRIBUTING.md ├── package.json ├── .npmignore ├── .gitignore └── README.md /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | semi: false, 4 | trailingComma: 'none' 5 | } 6 | -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -n "$CI" ] && exit 0 3 | 4 | . "$(dirname "$0")/_/husky.sh" 5 | 6 | npm run lint && npm test 7 | -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vultr/vultr-node/HEAD/docs/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -n "$CI" ] && exit 0 3 | 4 | . "$(dirname "$0")/_/husky.sh" 5 | 6 | npm run lint && npm run prettier && npm test 7 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "outDir": "./dist", 5 | "declaration": true 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - docs/.* 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: 75% 8 | patch: 9 | default: 10 | target: 75% -------------------------------------------------------------------------------- /test/config.js: -------------------------------------------------------------------------------- 1 | exports.apiKey = '123456789123456789123456789123456789' 2 | exports.baseUrl = 'https://api.vultr.com/v2' 3 | exports.headers = { 4 | reqheaders: { 5 | authorization: 'Bearer 123456789123456789123456789123456789' 6 | } 7 | } 8 | exports.rateLimit = 700 9 | -------------------------------------------------------------------------------- /.github/workflows/notify-pr.yml: -------------------------------------------------------------------------------- 1 | name: notify-pr 2 | 3 | on: pull_request_target 4 | 5 | jobs: 6 | pr: 7 | uses: vultr/shared-actions/.github/workflows/notify-pr.yml@main 8 | secrets: inherit 9 | with: 10 | repository: ${{ github.repository }} 11 | pr_number: ${{ github.event.number }} 12 | -------------------------------------------------------------------------------- /.github/workflows/notify-issue.yml: -------------------------------------------------------------------------------- 1 | name: notify-issue 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | 7 | jobs: 8 | pr: 9 | uses: vultr/shared-actions/.github/workflows/notify-issue.yml@main 10 | secrets: inherit 11 | with: 12 | repository: ${{ github.repository }} 13 | issue_number: ${{ github.event.issue.number }} 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | node: true, 5 | 'jest/globals': true 6 | }, 7 | extends: 'standard', 8 | globals: { 9 | Atomics: 'readonly', 10 | SharedArrayBuffer: 'readonly' 11 | }, 12 | parserOptions: { 13 | ecmaVersion: 2018, 14 | sourceType: 'module' 15 | }, 16 | plugins: ['jest'], 17 | rules: {} 18 | } 19 | -------------------------------------------------------------------------------- /test/api/operating-systems.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockResponses = { 4 | listImages: { 5 | os: [ 6 | { 7 | id: 127, 8 | name: 'CentOS 6 x64', 9 | arch: 'x64', 10 | family: 'centos' 11 | } 12 | ], 13 | meta: { 14 | total: 1, 15 | links: { 16 | next: '', 17 | prev: '' 18 | } 19 | } 20 | } 21 | } 22 | 23 | util.createTestSuite('operating-systems', null, mockResponses) 24 | -------------------------------------------------------------------------------- /src/api/account.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the account endpoints
3 | * {@link https://www.vultr.com/api/#tag/account} 4 | * @namespace account 5 | */ 6 | 7 | /** 8 | * Get your Vultr account, permissions, and billing information.
9 | * {@link https://www.vultr.com/api/#operation/get-account} 10 | * @function getAccountInfo 11 | * @memberof account 12 | * @instance 13 | */ 14 | exports.getAccountInfo = { 15 | url: '/account', 16 | requestType: 'GET', 17 | apiKeyRequired: true 18 | } 19 | -------------------------------------------------------------------------------- /src/api/applications.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the application endpoints
3 | * {@link https://www.vultr.com/api/#tag/application} 4 | * @namespace applications 5 | */ 6 | 7 | /** 8 | * Get a list of all One-Click applications.
9 | * {@link https://www.vultr.com/api/#operation/list-applications} 10 | * @function list 11 | * @memberof applications 12 | * @instance 13 | */ 14 | exports.listApplications = { 15 | url: '/applications', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'number' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/api/operating-systems.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the operating system endpoints
3 | * {@link https://www.vultr.com/api/#tag/os} 4 | * @namespace operatingSystems 5 | */ 6 | 7 | /** 8 | * Get a list of all OS images available to install from Vultr.
9 | * {@link https://www.vultr.com/api/#operation/list-os} 10 | * @function listImages 11 | * @memberof operatingSystems 12 | * @instance 13 | */ 14 | exports.listImages = { 15 | url: '/os', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'string' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docs/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (() => { 3 | const source = document.getElementsByClassName('prettyprint source linenums'); 4 | let i = 0; 5 | let lineNumber = 0; 6 | let lineId; 7 | let lines; 8 | let totalLines; 9 | let anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = `line${lineNumber}`; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /test/api/account.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockResponses = { 4 | getAccountInfo: { 5 | account: { 6 | name: 'vultr-api', 7 | email: 'api@vultr.com', 8 | acls: [ 9 | 'manage_users', 10 | 'subscriptions_view', 11 | 'subscriptions', 12 | 'billing', 13 | 'support', 14 | 'provisioning', 15 | 'dns', 16 | 'abuse', 17 | 'upgrade', 18 | 'firewall', 19 | 'alerts', 20 | 'objstore', 21 | 'loadbalancer' 22 | ], 23 | balance: -100, 24 | pending_charges: 60, 25 | last_payment_date: '2020-10-10T01:56:20+00:00', 26 | last_payment_amount: -1 27 | } 28 | } 29 | } 30 | 31 | util.createTestSuite('account', null, mockResponses) 32 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /src/api/plans.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the plan endpoints
3 | * {@link https://www.vultr.com/api/#tag/plans} 4 | * @namespace plans 5 | */ 6 | 7 | /** 8 | * Get a list of allavailable Vultr instance plans.
9 | * {@link https://www.vultr.com/api/#operation/list-plans} 10 | * @function listPlans 11 | * @memberof plans 12 | * @instance 13 | */ 14 | exports.listPlans = { 15 | url: '/plans', 16 | requestType: 'GET', 17 | parameters: { 18 | type: { type: 'string' }, 19 | os: { type: 'string' }, 20 | per_page: { type: 'string' }, 21 | cursor: { type: 'string' } 22 | } 23 | } 24 | /** 25 | * Get a list of all available Vultr bare metal plans.
26 | * {@link https://www.vultr.com/api/#operation/list-metal-plans} 27 | * @function listBareMetalPlans 28 | * @memberof plans 29 | * @instance 30 | */ 31 | exports.listBareMetalPlans = { 32 | url: '/plans-metal', 33 | requestType: 'GET', 34 | parameters: { 35 | per_page: { type: 'string' }, 36 | cursor: { type: 'string' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/api/backups.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | listBackups: { 5 | instance_id: '1', 6 | per_page: 100, 7 | cursor: '' 8 | }, 9 | getBackup: { 10 | 'backup-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 11 | } 12 | } 13 | 14 | const mockResponses = { 15 | listBackups: { 16 | backups: [ 17 | { 18 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 19 | date_created: '2020-10-10T01:56:20+00:00', 20 | description: 'auto-backup', 21 | size: 10000000, 22 | status: 'complete' 23 | } 24 | ], 25 | meta: { 26 | total: 1, 27 | links: { 28 | next: '', 29 | prev: '' 30 | } 31 | } 32 | }, 33 | getBackup: { 34 | backup: { 35 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 36 | date_created: '2020-10-10T01:56:20+00:00', 37 | description: '', 38 | size: 10000000, 39 | status: 'complete' 40 | } 41 | } 42 | } 43 | 44 | util.createTestSuite('backups', mockParameters, mockResponses) 45 | -------------------------------------------------------------------------------- /test/api/applications.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | listApplications: { 5 | per_page: 100, 6 | cursor: '' 7 | } 8 | } 9 | 10 | const mockResponses = { 11 | listApplications: { 12 | applications: [ 13 | { 14 | id: 1, 15 | name: 'LEMP', 16 | short_name: 'lemp', 17 | deploy_name: 'LEMP on CentOS 6 x64', 18 | type: 'one-click', 19 | vendor: 'vultr', 20 | image_id: '' 21 | }, 22 | { 23 | id: 1028, 24 | name: 'OpenLiteSpeed WordPress', 25 | short_name: 'openlitespeedwordpress', 26 | deploy_name: 'OpenLiteSpeed WordPress on Ubuntu 20.04 x64', 27 | type: 'marketplace', 28 | vendor: 'LiteSpeed_Technologies', 29 | image_id: 'openlitespeed-wordpress' 30 | } 31 | ], 32 | meta: { 33 | total: 2, 34 | links: { 35 | next: '', 36 | prev: '' 37 | } 38 | } 39 | } 40 | } 41 | 42 | util.createTestSuite('applications', mockParameters, mockResponses) 43 | -------------------------------------------------------------------------------- /test/api/plans.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockResponses = { 4 | listPlans: { 5 | plans: [ 6 | { 7 | id: 'vhf-8c-32gb', 8 | vcpu_count: 8, 9 | ram: 32768, 10 | disk: 512, 11 | bandwidth: 6144, 12 | monthly_cost: 192, 13 | type: 'vhf', 14 | locations: ['sea'] 15 | } 16 | ], 17 | meta: { 18 | total: 1, 19 | links: { 20 | next: '', 21 | prev: '' 22 | } 23 | } 24 | }, 25 | listBareMetalPlans: { 26 | plans_metal: [ 27 | { 28 | id: 'vbm-4c-32gb', 29 | cpu_count: 4, 30 | cpu_threads: 8, 31 | cpu_model: 'E3-1270v6', 32 | ram: 32768, 33 | disk: 240, 34 | bandwidth: 5120, 35 | monthly_cost: 300, 36 | type: 'SSD', 37 | locations: ['ewr'] 38 | } 39 | ], 40 | meta: { 41 | total: 1, 42 | links: { 43 | next: '', 44 | prev: '' 45 | } 46 | } 47 | } 48 | } 49 | 50 | util.createTestSuite('plans', null, mockResponses) 51 | -------------------------------------------------------------------------------- /src/api/backups.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the backup endpoints
3 | * {@link https://www.vultr.com/api/#tag/backup} 4 | * @namespace backup 5 | */ 6 | 7 | /** 8 | * Get information about backups in your account.
9 | * {@link https://www.vultr.com/api/#operation/list-backups} 10 | * @function list 11 | * @memberof backup 12 | * @instance 13 | */ 14 | exports.listBackups = { 15 | url: '/backups', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | instance_id: { type: 'string' }, 20 | per_page: { type: 'number' }, 21 | cursor: { type: 'string' } 22 | } 23 | } 24 | 25 | /** 26 | * Get information for the specified backup.
27 | * {@link https://www.vultr.com/api/#operation/get-backup} 28 | * @function get 29 | * @memberof backup 30 | * @instance 31 | */ 32 | exports.getBackup = { 33 | url: '/backups/{backup-id}', 34 | requestType: 'GET', 35 | apiKeyRequired: true, 36 | parameters: { 37 | 'backup-id': { 38 | type: 'string', 39 | path: true, 40 | required: true 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/api/regions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the region endpoints
3 | * {@link https://www.vultr.com/api/#tag/region} 4 | * @namespace regions 5 | */ 6 | 7 | /** 8 | * List all regions available at Vultr.
9 | * {@link https://www.vultr.com/api/#operation/list-regions} 10 | * @function listRegions 11 | * @memberof regions 12 | * @instance 13 | */ 14 | exports.listRegions = { 15 | url: '/regions', 16 | requestType: 'GET', 17 | parameters: { 18 | per_page: { type: 'string' }, 19 | cursor: { type: 'string' } 20 | } 21 | } 22 | 23 | /** 24 | * List all available plans in the specified region.
25 | * {@link https://www.vultr.com/api/#operation/list-available-compute-region} 26 | * @function listAvailableComputeInRegion 27 | * @memberof regions 28 | * @instance 29 | */ 30 | exports.listAvailableComputeInRegion = { 31 | url: '/regions/{region-id}/availability', 32 | requestType: 'GET', 33 | parameters: { 34 | 'region-id': { 35 | type: 'string', 36 | path: true, 37 | required: true 38 | }, 39 | type: { type: 'string' } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Vultr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/api/ssh-keys.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getSshKey: { 5 | 'ssh-key-id': '5f1c8911af06f' 6 | }, 7 | updateSshKey: { 8 | 'ssh-key-id': '5f1c8911af06f' 9 | }, 10 | deleteSshKey: { 11 | 'ssh-key-id': '5f1c8911af06f' 12 | }, 13 | createSshKey: { 14 | name: 'my SSH key', 15 | ssh_key: 'ssh-rsa AA... test@example.com' 16 | } 17 | } 18 | 19 | const mockResponses = { 20 | getSshKey: { 21 | ssh_key: { 22 | id: '5f1c8911af06f', 23 | date_created: '2020-10-10T01:56:20+00:00', 24 | name: 'my ssh key', 25 | ssh_key: 'ssh-rsa AA... test@example.com' 26 | } 27 | }, 28 | listSshKeys: { 29 | ssh_key: { 30 | id: '5f1c8911af06f', 31 | date_created: '2020-10-10T01:56:20+00:00', 32 | name: 'my ssh key', 33 | ssh_key: 'ssh-rsa AA... test@example.com' 34 | } 35 | }, 36 | createSshKey: { 37 | ssh_key: { 38 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 39 | date_created: '2020-10-10T01:56:20+00:00', 40 | name: 'my ssh key', 41 | ssh_key: 'ssh-rsa AA... test@example.com' 42 | } 43 | } 44 | } 45 | 46 | util.createTestSuite('ssh-keys', mockParameters, mockResponses) 47 | -------------------------------------------------------------------------------- /test/api/regions.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | listAvailableComputeInRegion: { 5 | 'region-id': 'ewr' 6 | } 7 | } 8 | 9 | const mockResponses = { 10 | listRegions: { 11 | regions: [ 12 | { 13 | id: 'ams', 14 | city: 'Amsterdam', 15 | country: 'NL', 16 | continent: 'Europe', 17 | options: ['ddos_protection'] 18 | } 19 | ], 20 | meta: { 21 | total: 1, 22 | links: { 23 | next: '', 24 | prev: '' 25 | } 26 | } 27 | }, 28 | listAvailableComputeInRegion: { 29 | available_plans: [ 30 | 'vc2-1c-1gb', 31 | 'vc2-1c-2gb', 32 | 'vc2-2c-4gb', 33 | 'vc2-4c-8gb', 34 | 'vc2-6c-16gb', 35 | 'vc2-8c-32gb', 36 | 'vc2-16c-64gb', 37 | 'vc2-24c-96gb', 38 | 'vdc-4vcpu-8gb', 39 | 'vdc-4vcpu-16gb', 40 | 'vdc-6vcpu-24gb', 41 | 'vdc-8vcpu-32gb', 42 | 'vhf-1c-1gb', 43 | 'vhf-1c-2gb', 44 | 'vhf-2c-4gb', 45 | 'vhf-3c-8gb', 46 | 'vhf-4c-16gb', 47 | 'vhf-6c-24gb', 48 | 'vhf-8c-32gb', 49 | 'vhf-12c-48gb' 50 | ] 51 | } 52 | } 53 | 54 | util.createTestSuite('regions', mockParameters, mockResponses) 55 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to `vultr-node` 2 | 3 | We would love to get your feedback, thoughts, and overall improvements to `vultr-node`! 4 | 5 | ## Overview 6 | 7 | We use Husky to create a lint and test hook before each commit and push to maintain consistency and ensure code is tested thoroughly. Please be sure to respect these build steps. 8 | 9 | ## Getting started 10 | 11 | You will need to fork the `vultr-node` repository and submit pull requests off of your fork. 12 | 13 | 14 | ## Testing 15 | 16 | We aim to have as much code coverage as possible. 17 | 18 | To run tests locally: 19 | 20 | ``` 21 | npm run test 22 | ``` 23 | 24 | ## Versioning 25 | 26 | vultr-node follows [SemVer](http://semver.org/) for versioning. New functionality will result in a increment to the minor version. While, 27 | bug fixes will result in a increment to the patch version. 28 | 29 | ## Releases 30 | Releases of new versions are done as their independent pull requests - They will also be done by the maintainers. 31 | 32 | To release a new version of `vultr-node` we must do the following. 33 | 34 | - Make the appropriate updates to `CHANGELOG.md`. This should include the 35 | - Version, 36 | - List of fix/features with accompanying pull request ID 37 | - Description of each fix/feature 38 | 39 | ``` 40 | ## v0.0.1 (2019-06-12) 41 | 42 | ### Fixes 43 | * Fixed random bug #12 44 | ``` 45 | - Submit a pull request with the following changes 46 | - Once the pull request is merged in - create a new tag and publish. 47 | -------------------------------------------------------------------------------- /test/api/vpcs.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getVpc: { 5 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | deleteVpc: { 8 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateVpc: { 11 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 12 | description: 'my new label' 13 | }, 14 | createVpc: { 15 | region: 'ewr' 16 | } 17 | } 18 | 19 | const mockResponses = { 20 | getVpc: { 21 | vpc: { 22 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 23 | date_created: '2020-10-10T01:56:20+00:00', 24 | region: 'ewr', 25 | description: 'Example VPC Description', 26 | v4_subnet: '10.99.0.0', 27 | v4_subnet_mask: 24 28 | } 29 | }, 30 | listVpcs: { 31 | vpcs: [ 32 | { 33 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 34 | region: 'ewr', 35 | date_created: '2020-10-10T01:56:20+00:00', 36 | description: 'sample desc', 37 | v4_subnet: '10.99.0.0', 38 | v4_subnet_mask: 24 39 | } 40 | ], 41 | meta: { 42 | total: 1, 43 | links: { 44 | next: '', 45 | prev: '' 46 | } 47 | } 48 | }, 49 | createVpc: { 50 | vpc: { 51 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 52 | date_created: '2020-10-10T01:56:20+00:00', 53 | region: 'ewr', 54 | description: 'Example VPC Description', 55 | v4_subnet: '10.99.0.0', 56 | v4_subnet_mask: 24 57 | } 58 | } 59 | } 60 | 61 | util.createTestSuite('vpcs', mockParameters, mockResponses) 62 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vultr/vultr-node", 3 | "private": false, 4 | "version": "2.8.0", 5 | "description": "Node module to communicate with the Vultr API", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "scripts": { 9 | "build": "babel src -d dist && tsc", 10 | "test": "jest", 11 | "lint": "eslint src", 12 | "prettier": "prettier --write src", 13 | "docs": "jsdoc --readme ./README.md ./src/api -r -d docs", 14 | "prepare": "husky install" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/vultr/vultr-node.git" 19 | }, 20 | "keywords": [ 21 | "vultr", 22 | "node", 23 | "api" 24 | ], 25 | "author": "Vultr", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/vultr/vultr-node/issues" 29 | }, 30 | "homepage": "https://github.com/vultr/vultr-node#readme", 31 | "devDependencies": { 32 | "@babel/cli": "^7.10.1", 33 | "@babel/core": "^7.10.2", 34 | "@babel/preset-env": "^7.10.2", 35 | "eslint": "^8.20.0", 36 | "eslint-config-standard": "^17.0.0", 37 | "eslint-plugin-import": "^2.21.2", 38 | "eslint-plugin-jest": "^27.0.1", 39 | "eslint-plugin-node": "^11.0.0", 40 | "eslint-plugin-promise": "^6.0.0", 41 | "husky": "^8.0.1", 42 | "jest": "^29.0.1", 43 | "jsdoc": "^4.0.0", 44 | "prettier": "^2.0.5" 45 | }, 46 | "dependencies": { 47 | "node-fetch": "^2.6.0", 48 | "typescript": "^4.3.5" 49 | }, 50 | "directories": { 51 | "test": "test" 52 | }, 53 | "publishConfig": { 54 | "access": "public" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Code Coverage test 2 | 3 | on: pull_request_target 4 | 5 | jobs: 6 | coverage: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v4 11 | 12 | - name: Setup node 13 | uses: actions/setup-node@v2 14 | with: 15 | node-version: '16' 16 | 17 | - name: Install dependencies 18 | run: | 19 | npm install -g jest 20 | npm install -g husky 21 | npm install 22 | 23 | - name: Perform Tests 24 | run: | 25 | npm run test >> output.txt 26 | npm run build 27 | jest --ci --coverage >> output.txt 28 | 29 | - name: Transform output 30 | id: results 31 | if: always() 32 | run: | 33 | CONTENT=$(cat output.txt) 34 | CONTENT="${CONTENT//'%'/'%25'}" 35 | CONTENT="${CONTENT//$'\n'/'%0A'}" 36 | CONTENT="${CONTENT//$'\r'/'%0D'}" 37 | echo "::set-output name=content::$CONTENT" 38 | 39 | - name: Add Comment 40 | uses: actions/github-script@v5 41 | if: always() 42 | with: 43 | script: | 44 | const output = `### Unit Tests and Coverage 45 |
Show Output 46 | ${{ steps.results.outputs.content }} 47 |
48 | *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; 49 | await github.rest.issues.createComment({ 50 | issue_number: context.issue.number, 51 | owner: context.repo.owner, 52 | repo: context.repo.repo, 53 | body: output 54 | }) -------------------------------------------------------------------------------- /test/api/startup-scripts.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getStartupScript: { 5 | 'startup-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | deleteStartupScript: { 8 | 'startup-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateStartupScript: { 11 | 'startup-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 12 | }, 13 | createStartupScript: { 14 | name: 'my start up script', 15 | script: 'aGVsbG8gd29ybGQ=' 16 | } 17 | } 18 | 19 | const mockResponses = { 20 | getStartupScript: { 21 | startup_script: { 22 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 23 | date_created: '2020-10-10T01:56:20+00:00', 24 | date_modified: '2020-10-10T01:59:20+00:00', 25 | name: 'worker-node', 26 | type: 'pxe', 27 | script: 'aGVsbG8gd29ybGQ=' 28 | } 29 | }, 30 | listStartupScripts: { 31 | startup_scripts: [ 32 | { 33 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 34 | date_created: '2020-10-10T01:56:20+00:00', 35 | date_modified: '2020-10-10T01:59:20+00:00', 36 | name: 'startup script', 37 | type: 'pxe' 38 | } 39 | ], 40 | meta: { 41 | total: 1, 42 | links: { 43 | next: '', 44 | prev: '' 45 | } 46 | } 47 | }, 48 | createStartupScript: { 49 | startup_script: { 50 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 51 | date_created: '2020-10-10T01:56:20+00:00', 52 | date_modified: '2020-10-10T01:56:20+00:00', 53 | name: 'worker-node', 54 | type: 'pxe', 55 | script: 'aGVsbG8gd29ybGQ=' 56 | } 57 | } 58 | } 59 | 60 | util.createTestSuite('startup-scripts', mockParameters, mockResponses) 61 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | .env.test 68 | 69 | # parcel-bundler cache (https://parceljs.org/) 70 | .cache 71 | 72 | # next.js build output 73 | .next 74 | 75 | # nuxt.js build output 76 | .nuxt 77 | 78 | # vuepress build output 79 | .vuepress/dist 80 | 81 | # Serverless directories 82 | .serverless/ 83 | 84 | # FuseBox cache 85 | .fusebox/ 86 | 87 | # DynamoDB Local files 88 | .dynamodb/ 89 | 90 | # Mac os 91 | .DS_Store 92 | 93 | # IDE 94 | .idea -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | .env.test 68 | 69 | # parcel-bundler cache (https://parceljs.org/) 70 | .cache 71 | 72 | # next.js build output 73 | .next 74 | 75 | # nuxt.js build output 76 | .nuxt 77 | 78 | # vuepress build output 79 | .vuepress/dist 80 | 81 | # Serverless directories 82 | .serverless/ 83 | 84 | # FuseBox cache 85 | .fusebox/ 86 | 87 | # DynamoDB Local files 88 | .dynamodb/ 89 | 90 | # Mac os 91 | .DS_Store 92 | 93 | # IDE 94 | .idea 95 | 96 | dist/ 97 | -------------------------------------------------------------------------------- /test/api/iso.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | createIso: { 5 | url: 'https://someurl.com/my-iso.iso' 6 | }, 7 | getIso: { 8 | 'iso-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | deleteIso: { 11 | 'iso-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 12 | } 13 | } 14 | 15 | const mockResponses = { 16 | listIsos: { 17 | isos: [ 18 | { 19 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 20 | date_created: '2020-10-10T01:56:20+00:00', 21 | filename: 'my-iso.iso', 22 | size: 120586240, 23 | md5sum: '77ba289bdc966ec996278a5a740d96d8', 24 | sha512sum: 25 | '2b31b6fcab34d6ea9a6b293601c39b90cb044e5679fcc5f71838d389459527079ce2b2cd9595e8cc727c7818f9166e8caa326ddaf832dcf8444162291da6214e', 26 | status: 'complete' 27 | } 28 | ], 29 | meta: { 30 | total: 1, 31 | links: { 32 | next: '', 33 | prev: '' 34 | } 35 | } 36 | }, 37 | createIso: { 38 | iso: { 39 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 40 | date_created: '2020-10-10T01:56:20+00:00', 41 | filename: 'my-iso.iso', 42 | status: 'pending' 43 | } 44 | }, 45 | getIso: { 46 | iso: { 47 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 48 | date_created: '2020-10-10T01:56:20+00:00', 49 | filename: 'alpine-standard-3.12.0-x86.iso', 50 | size: 120586240, 51 | md5sum: '77ba289bdc966ec996278a5a740d96d8', 52 | sha512sum: 53 | '2b31b6fcab34d6ea9a6b293601c39b90cb044e5679fcc5f71838d389459527079ce2b2cd9595e8cc727c7818f9166e8caa326ddaf832dcf8444162291da6214e', 54 | status: 'complete' 55 | } 56 | } 57 | } 58 | 59 | util.createTestSuite('iso', mockParameters, mockResponses) 60 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [master, ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [master] 9 | schedule: 10 | - cron: '0 19 * * 0' 11 | 12 | jobs: 13 | analyse: 14 | name: Analyse 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v4 20 | with: 21 | # We must fetch at least the immediate parents so that if this is 22 | # a pull request then we can checkout the head. 23 | fetch-depth: 2 24 | 25 | # If this run was triggered by a pull request event, then checkout 26 | # the head of the pull request instead of the merge commit. 27 | - run: git checkout HEAD^2 28 | if: ${{ github.event_name == 'pull_request' }} 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v1 33 | # Override language selection by uncommenting this and choosing your languages 34 | with: 35 | languages: javascript 36 | 37 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 38 | # If this step fails, then you should remove it and run the build manually (see below) 39 | - name: Autobuild 40 | uses: github/codeql-action/autobuild@v1 41 | 42 | # ℹ️ Command-line programs to run using the OS shell. 43 | # 📚 https://git.io/JvXDl 44 | 45 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 46 | # and modify them (or add more) to build your code if your project 47 | # uses a compiled language 48 | 49 | #- run: | 50 | # make bootstrap 51 | # make release 52 | 53 | - name: Perform CodeQL Analysis 54 | uses: github/codeql-action/analyze@v1 55 | -------------------------------------------------------------------------------- /src/api/billing.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the billing endpoints
3 | * {@link https://www.vultr.com/api/#tag/billing} 4 | * @namespace billing 5 | */ 6 | 7 | /** 8 | * Retrieves a list of all billing history on the current account.
9 | * {@link https://www.vultr.com/api/#operation/list-billing-history} 10 | * @function listHistory 11 | * @memberof billing 12 | * @instance 13 | */ 14 | exports.listHistory = { 15 | url: '/billing/history', 16 | requestType: 'GET', 17 | apiKeyRequired: true 18 | } 19 | 20 | /** 21 | * Retrieves a list of all billing invoices on the current account.
22 | * {@link https://www.vultr.com/api/#operation/list-invoices} 23 | * @function listInvoices 24 | * @memberof billing 25 | * @instance 26 | */ 27 | exports.listInvoices = { 28 | url: '/billing/invoices', 29 | requestType: 'GET', 30 | apiKeyRequired: true 31 | } 32 | 33 | /** 34 | * Retrieves the invoice that matches the given invoice-id.
35 | * {@link https://www.vultr.com/api/#operation/get-invoice} 36 | * @function getInvoice 37 | * @memberof billing 38 | * @instance 39 | */ 40 | exports.getInvoice = { 41 | url: '/billing/invoices/{invoice-id}', 42 | requestType: 'GET', 43 | apiKeyRequired: true, 44 | parameters: { 45 | 'invoice-id': { 46 | type: 'string', 47 | path: true, 48 | required: true 49 | } 50 | } 51 | } 52 | 53 | /** 54 | * Retrieves items in the invoice that matches the given invoice-id.
55 | * {@link https://www.vultr.com/api/#operation/get-invoice-items} 56 | * @function listInvoiceItems 57 | * @memberof billing 58 | * @instance 59 | */ 60 | exports.listInvoiceItems = { 61 | url: '/billing/invoices/{invoice-id}/items', 62 | requestType: 'GET', 63 | apiKeyRequired: true, 64 | parameters: { 65 | 'invoice-id': { 66 | type: 'string', 67 | path: true, 68 | required: true 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /test/api/block-storage.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | createStorage: { 5 | region: 'ewr', 6 | size_gb: 50 7 | }, 8 | getStorage: { 9 | 'block-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 10 | }, 11 | deleteStorage: { 12 | 'block-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 13 | }, 14 | updateStorage: { 15 | 'block-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 16 | }, 17 | attachStorage: { 18 | 'block-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 19 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 20 | }, 21 | detachStorage: { 22 | 'block-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 23 | } 24 | } 25 | 26 | const mockResponses = { 27 | listStorages: { 28 | blocks: [ 29 | { 30 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 31 | date_created: '2020-10-10T01:56:20+00:00', 32 | cost: 5, 33 | status: 'pending', 34 | size_gb: 50, 35 | region: 'ewr', 36 | attached_to_instance: 0, 37 | label: 'my label' 38 | } 39 | ], 40 | meta: { 41 | total: 1, 42 | links: { 43 | next: '', 44 | prev: '' 45 | } 46 | } 47 | }, 48 | createStorage: { 49 | block: { 50 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 51 | date_created: '2020-10-10T01:56:20+00:00', 52 | cost: 5, 53 | status: 'active', 54 | size_gb: 50, 55 | region: 'ewr', 56 | attached_to_instance: 0, 57 | label: 'my label', 58 | mount_id: 'ewr-example112233', 59 | block_type: 'high_perf' 60 | } 61 | }, 62 | getStorage: { 63 | block: { 64 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 65 | date_created: '2020-10-10T01:56:20+00:00', 66 | cost: 5, 67 | status: 'active', 68 | size_gb: 50, 69 | region: 'ewr', 70 | attached_to_instance: 0, 71 | label: 'my label' 72 | } 73 | } 74 | } 75 | 76 | util.createTestSuite('block-storage', mockParameters, mockResponses) 77 | -------------------------------------------------------------------------------- /test/api/snapshots.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | deleteSnapshot: { 5 | 'snapshot-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | getSnapshot: { 8 | 'snapshot-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateSnapshot: { 11 | 'snapshot-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 12 | description: 'my snapshot' 13 | }, 14 | createSnapshot: { 15 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 16 | }, 17 | createSnapshotFromUrl: { 18 | url: 'http://example.com/path/to/disk_image.raw' 19 | } 20 | } 21 | 22 | const mockResponses = { 23 | getSnapshot: { 24 | snapshot: { 25 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 26 | date_created: '2020-10-10T01:56:20+00:00', 27 | description: 'Test snapshot', 28 | size: 42949672960, 29 | status: 'complete', 30 | os_id: 127, 31 | app_id: 0 32 | } 33 | }, 34 | listSnapshots: { 35 | snapshots: [ 36 | { 37 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 38 | date_created: '2020-10-10T01:56:20+00:00', 39 | description: 'Test snapshot', 40 | size: 42949672960, 41 | status: 'complete', 42 | os_id: 127, 43 | app_id: 0 44 | } 45 | ], 46 | meta: { 47 | total: 1, 48 | links: { 49 | next: '', 50 | prev: '' 51 | } 52 | } 53 | }, 54 | createSnapshot: { 55 | snapshot: { 56 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 57 | date_created: '2020-10-10T01:56:20+00:00', 58 | description: 'my description', 59 | size: 42949672960, 60 | status: 'complete', 61 | os_id: 127, 62 | app_id: 0 63 | } 64 | }, 65 | createSnapshotFromUrl: { 66 | snapshot: { 67 | id: 'abcd12345', 68 | date_created: '2020-10-10T01:56:20+00:00', 69 | description: 'disk_image.raw', 70 | size: 0, 71 | status: 'pending', 72 | os_id: 159, 73 | app_id: 0 74 | } 75 | } 76 | } 77 | 78 | util.createTestSuite('snapshots', mockParameters, mockResponses) 79 | -------------------------------------------------------------------------------- /docs/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /src/api/iso.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the ISO endpoints
3 | * {@link https://www.vultr.com/api/#tag/iso} 4 | * @namespace iso 5 | */ 6 | 7 | /** 8 | * List all ISOs in the account.
9 | * {@link https://www.vultr.com/api/#operation/list-isos} 10 | * @function listIsos 11 | * @memberof iso 12 | * @instance 13 | */ 14 | exports.listIsos = { 15 | url: '/iso', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'string' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | 24 | /** 25 | * Create a new ISO in the account from a URL.
26 | * {@link https://www.vultr.com/api/#operation/create-iso} 27 | * @function createIso 28 | * @memberof iso 29 | * @instance 30 | */ 31 | exports.createIso = { 32 | url: '/iso', 33 | requestType: 'POST', 34 | apiKeyRequired: true, 35 | parameters: { 36 | url: { 37 | type: 'string', 38 | required: true 39 | } 40 | } 41 | } 42 | 43 | /** 44 | * Get information about the specified ISO.
45 | * {@link https://www.vultr.com/api/#operation/iso-get} 46 | * @function getIso 47 | * @memberof iso 48 | * @instance 49 | */ 50 | exports.getIso = { 51 | url: '/iso/{iso-id}', 52 | requestType: 'POST', 53 | apiKeyRequired: true, 54 | parameters: { 55 | 'iso-id': { 56 | type: 'string', 57 | path: true, 58 | required: true 59 | } 60 | } 61 | } 62 | 63 | /** 64 | * Delete the specified ISO from the account.
65 | * {@link https://www.vultr.com/api/#operation/delete-iso} 66 | * @function deleteIso 67 | * @memberof iso 68 | * @instance 69 | */ 70 | exports.deleteIso = { 71 | url: '/iso/{iso-id}', 72 | requestType: 'DELETE', 73 | apiKeyRequired: true, 74 | parameters: { 75 | 'iso-id': { 76 | type: 'string', 77 | path: true, 78 | required: true 79 | } 80 | } 81 | } 82 | 83 | /** 84 | * List all Vultr public ISOs.
85 | * {@link https://www.vultr.com/api/#operation/list-public-isos} 86 | * @function listPublicIsos 87 | * @memberof iso 88 | * @instance 89 | */ 90 | exports.listPublicIsos = { 91 | url: '/iso-public', 92 | requestType: 'GET' 93 | } 94 | -------------------------------------------------------------------------------- /test/api/users.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getUser: { 5 | 'user-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | deleteUser: { 8 | 'user-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateUser: { 11 | 'user-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 12 | }, 13 | createUser: { 14 | email: 'api@vultr.com', 15 | name: 'Vultr Api', 16 | password: 'password' 17 | } 18 | } 19 | 20 | const mockResponses = { 21 | getUser: { 22 | user: { 23 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 24 | email: 'api@vultr.com', 25 | api_enabled: true, 26 | acls: [ 27 | 'manage_users', 28 | 'subscriptions_view', 29 | 'subscriptions', 30 | 'provisioning', 31 | 'billing', 32 | 'support', 33 | 'abuse', 34 | 'dns', 35 | 'upgrade', 36 | 'objstore', 37 | 'loadbalancer' 38 | ] 39 | } 40 | }, 41 | getUsers: { 42 | users: [ 43 | { 44 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 45 | email: 'api@vultr.com', 46 | api_enabled: true, 47 | acls: [ 48 | 'manage_users', 49 | 'subscriptions_view', 50 | 'subscriptions', 51 | 'provisioning', 52 | 'billing', 53 | 'support', 54 | 'abuse', 55 | 'dns', 56 | 'upgrade', 57 | 'objstore', 58 | 'loadbalancer' 59 | ] 60 | } 61 | ], 62 | meta: { 63 | total: 1, 64 | links: { 65 | next: '', 66 | prev: '' 67 | } 68 | } 69 | }, 70 | createUser: { 71 | user: { 72 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 73 | name: 'vultr api', 74 | email: 'api123@vultr.com', 75 | api_key: 'YRMPYNEIG5JO', 76 | api_enabled: true, 77 | acls: [ 78 | 'manage_users', 79 | 'subscriptions_view', 80 | 'subscriptions', 81 | 'provisioning', 82 | 'billing', 83 | 'support', 84 | 'abuse', 85 | 'dns', 86 | 'upgrade', 87 | 'objstore', 88 | 'loadbalancer' 89 | ] 90 | } 91 | } 92 | } 93 | 94 | util.createTestSuite('users', mockParameters, mockResponses) 95 | -------------------------------------------------------------------------------- /test/api/vpc2.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getVpc: { 5 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | deleteVpc: { 8 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateVpc: { 11 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 12 | description: 'new-label' 13 | }, 14 | createVpc: { 15 | region: 'ewr' 16 | }, 17 | listVpcNodes: { 18 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 19 | }, 20 | attachVpcNodes: { 21 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 22 | nodes: [ 23 | 'a4021db4-c1d0-43ba-8b5c-7a4a35444167', 24 | '12a43ca5-0025-40ef-9edb-3a475809a8c0' 25 | ] 26 | }, 27 | detachVpcNodes: { 28 | 'vpc-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 29 | nodes: [ 30 | 'a4021db4-c1d0-43ba-8b5c-7a4a35444167', 31 | '12a43ca5-0025-40ef-9edb-3a475809a8c0' 32 | ] 33 | } 34 | } 35 | 36 | const mockResponses = { 37 | getVpc: { 38 | vpc: { 39 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 40 | date_created: '2020-10-10T01:56:20+00:00', 41 | region: 'ewr', 42 | description: 'Example VPC Description', 43 | ip_block: '10.99.0.0', 44 | prefix_length: 24 45 | } 46 | }, 47 | listVpcs: { 48 | vpcs: [ 49 | { 50 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 51 | region: 'ewr', 52 | date_created: '2020-10-10T01:56:20+00:00', 53 | description: 'Example VPC Description', 54 | ip_block: '10.99.0.0', 55 | prefix_length: 24 56 | } 57 | ], 58 | meta: { 59 | total: 1, 60 | links: { 61 | next: '', 62 | prev: '' 63 | } 64 | } 65 | }, 66 | createVpc: { 67 | region: 'ewr', 68 | description: 'Example VPC', 69 | ip_block: '10.99.0.0', 70 | prefix_length: 24 71 | }, 72 | listVpcNodes: { 73 | nodes: [ 74 | { 75 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 76 | ip_address: '10.1.96.3', 77 | mac_address: '98964710968448', 78 | description: 'Example-Description', 79 | type: 'vps', 80 | node_status: 'active' 81 | } 82 | ], 83 | meta: { 84 | total: 1, 85 | links: { 86 | next: '', 87 | prev: '' 88 | } 89 | } 90 | } 91 | } 92 | 93 | util.createTestSuite('vpc2', mockParameters, mockResponses) 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Automatic Releaser](https://github.com/vultr/vultr-node/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/vultr/vultr-node/actions/workflows/release.yml) 2 | [![Code Coverage test](https://github.com/vultr/vultr-node/actions/workflows/coverage.yml/badge.svg)](https://github.com/vultr/vultr-node/actions/workflows/coverage.yml) 3 | [![npm version](https://badge.fury.io/js/%40vultr%2Fvultr-node.svg)](https://badge.fury.io/js/%40vultr%2Fvultr-node) 4 | [![license](https://img.shields.io/github/license/vultr/vultr-node)](https://github.com/vultr/vultr-node/blob/master/LICENSE.md) 5 | 6 | # vultr-node 7 | 8 | Official Vultr client node module. 9 | 10 | ## Installation 11 | 12 | ```sh 13 | npm install @vultr/vultr-node 14 | ``` 15 | 16 | ## Usage 17 | 18 | Vultr uses a PAT (Personal Access Token) to interact/authenticate with the APIs. An API Key can be generated and acquired from the API menu in [settings](https://my.vultr.com/settings/#settingsapi). 19 | 20 | ### Initialize 21 | 22 | ```js 23 | const VultrNode = require('@vultr/vultr-node') 24 | 25 | // Initialize the instance with your configuration 26 | const vultr = VultrNode.initialize({ 27 | apiKey: 'your-api-key-here', 28 | baseUrl: 'https://example.com', // Optional 29 | rateLimit: 600 // Optional 30 | }) 31 | ``` 32 | 33 | ### Calling Endpoints 34 | 35 | ```js 36 | // Call endpoints using Promises 37 | vultr.account.getAccountInfo().then((response) => { 38 | console.log(response) 39 | }) 40 | ``` 41 | 42 | ## Versioning 43 | 44 | This project follows [SemVer](https://semver.org/) for versioning. For the versions available, [see the tags on this repository](https://github.com/vultr/vultr-node/releases) 45 | 46 | ## Documentation 47 | 48 | This implements Vultr API V2. For documentation on all endpoints, please visit https://www.vultr.com/api/. To use Vultr API V1, please use the version of the library on the [V1 branch](https://github.com/vultr/vultr-node/tree/v1), or any version of this library before 2.0.0. 49 | 50 | For documentation specific to this client please visit https://vultr.github.io/vultr-node 51 | 52 | ## Contributing 53 | 54 | Feel free to send pull requests our way! Please see the [contributing guidelines](CONTRIBUTING.md). 55 | 56 | ## License 57 | 58 | This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details. 59 | 60 | ## Authors 61 | 62 | - [**Spencer Kordecki**](https://github.com/spencerkordecki) 63 | - [**Fady Farid**](https://github.com/afady) 64 | - [**Glenn Dobson**](https://github.com/afatalerrror) 65 | -------------------------------------------------------------------------------- /test/api/billing.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getInvoice: { 5 | 'invoice-id': '123456' 6 | }, 7 | listInvoiceItems: { 8 | 'invoice-id': '123456' 9 | } 10 | } 11 | 12 | const mockResponses = { 13 | listHistory: { 14 | billing_history: [ 15 | { 16 | id: 123456, 17 | date: '2020-10-10T01:56:20+00:00', 18 | type: 'invoice', 19 | description: 'Invoice #123456', 20 | amount: 100.03, 21 | balance: 79.48 22 | }, 23 | { 24 | id: 123457, 25 | date: '2020-10-10T01:46:05+00:00', 26 | type: 'credit', 27 | description: 'Account Credit', 28 | amount: 50.55, 29 | balance: -20.55 30 | } 31 | ], 32 | meta: { 33 | total: 3, 34 | links: { 35 | next: 'WxYzExampleNext', 36 | prev: '' 37 | } 38 | } 39 | }, 40 | listInvoices: { 41 | billing_invoices: [ 42 | { 43 | id: 123456, 44 | date: '2021-10-10T00:00:00+00:00', 45 | description: 'Invoice #123456', 46 | amount: 5.25, 47 | balance: 10.25 48 | } 49 | ], 50 | meta: { 51 | total: 1, 52 | links: { 53 | next: '', 54 | prev: '' 55 | } 56 | } 57 | }, 58 | getInvoice: { 59 | billing_invoice: { 60 | id: 123456, 61 | description: 'Account Credit', 62 | date: '09-01-2021T00:00:00+00:00', 63 | amount: 5.25 64 | } 65 | }, 66 | listInvoiceItems: { 67 | invoice_items: [ 68 | { 69 | description: 'Load Balancer (my-loadbalancer)', 70 | product: 'Load Balancer', 71 | start_date: '2021-08-31T00:00:00+00:00', 72 | end_date: '2021-09-30T00:00:00+00:00', 73 | units: 720, 74 | unit_type: 'hours', 75 | unit_price: 0.0149, 76 | total: 10 77 | }, 78 | { 79 | description: '1.1.1.1 (8192 MB) [my-instance]', 80 | product: 'Vultr Cloud Compute', 81 | start_date: '2021-09-15T00:00:00+00:00', 82 | end_date: '2021-09-30T00:00:00+00:00', 83 | units: 371, 84 | unit_type: 'hours', 85 | unit_price: 0.0595, 86 | total: 22.09 87 | } 88 | ], 89 | meta: { 90 | total: 3, 91 | links: { 92 | next: 'WxYzExampleNext', 93 | prev: '' 94 | } 95 | } 96 | } 97 | } 98 | 99 | util.createTestSuite('billing', mockParameters, mockResponses) 100 | -------------------------------------------------------------------------------- /src/api/ssh-keys.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the snapshot endpoints
3 | * {@link https://www.vultr.com/api/#tag/ssh} 4 | * @namespace sshKeys 5 | */ 6 | 7 | /** 8 | * Get information about a specified SSH key.
9 | * {@link https://www.vultr.com/api/#operation/get-ssh-key} 10 | * @function getSshKey 11 | * @memberof sshKeys 12 | * @instance 13 | */ 14 | exports.getSshKey = { 15 | url: '/ssh-keys/{ssh-key-id}', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'ssh-key-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Update information for the specified SSH key.
29 | * {@link https://www.vultr.com/api/#operation/update-ssh-key} 30 | * @function updateSshKey 31 | * @memberof sshKeys 32 | * @instance 33 | */ 34 | exports.updateSshKey = { 35 | url: '/ssh-keys/{ssh-key-id}', 36 | requestType: 'PATCH', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'ssh-key-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | }, 44 | name: { type: 'string' }, 45 | ssh_key: { type: 'string' } 46 | } 47 | } 48 | 49 | /** 50 | * Delete the specified SSH key.
51 | * {@link https://www.vultr.com/api/#operation/delete-ssh-key} 52 | * @function deleteSshKey 53 | * @memberof sshKeys 54 | * @instance 55 | */ 56 | exports.deleteSshKey = { 57 | url: '/ssh-keys/{ssh-key-id}', 58 | requestType: 'DELETE', 59 | apiKeyRequired: true, 60 | parameters: { 61 | 'ssh-key-id': { 62 | type: 'string', 63 | path: true, 64 | required: true 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * List all SSH keys on the account.
71 | * {@link https://www.vultr.com/api/#operation/list-ssh-keys} 72 | * @function listSshKeys 73 | * @memberof sshKeys 74 | * @instance 75 | */ 76 | exports.listSshKeys = { 77 | url: '/ssh-keys', 78 | requestType: 'GET', 79 | apiKeyRequired: true, 80 | parameters: { 81 | per_page: { type: 'string' }, 82 | cursor: { type: 'string' } 83 | } 84 | } 85 | 86 | /** 87 | * Create a new SSH key.
88 | * {@link https://www.vultr.com/api/#operation/create-ssh-key} 89 | * @function createSshKey 90 | * @memberof sshKeys 91 | * @instance 92 | */ 93 | exports.createSshKey = { 94 | url: '/ssh-keys', 95 | requestType: 'POST', 96 | apiKeyRequired: true, 97 | parameters: { 98 | name: { type: 'string' }, 99 | ssh_key: { type: 'string' } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/api/vpcs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the vpc endpoints
3 | * {@link https://www.vultr.com/api/#tag/VPCs} 4 | * @namespace vpcs 5 | */ 6 | 7 | /** 8 | * Get information about the specified vpc.
9 | * {@link https://www.vultr.com/api/#operation/get-vpc} 10 | * @function getVpc 11 | * @memberof vpcs 12 | * @instance 13 | */ 14 | exports.getVpc = { 15 | url: '/vpcs/{vpc-id}', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'vpc-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Delete a specified vpc.
29 | * {@link https://www.vultr.com/api/#operation/delete-vpc} 30 | * @function deleteVpc 31 | * @memberof vpcs 32 | * @instance 33 | */ 34 | exports.deleteVpc = { 35 | url: '/vpcs/{vpc-id}', 36 | requestType: 'DELETE', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'vpc-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information on the specified vpc.
49 | * {@link https://www.vultr.com/api/#operation/update-vpc} 50 | * @function updateVpc 51 | * @memberof vpcs 52 | * @instance 53 | */ 54 | exports.updateVpc = { 55 | url: '/vpcs/{vpc-id}', 56 | requestType: 'PUT', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'vpc-id': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | description: { 65 | type: 'string', 66 | required: true 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * List all vpcs on the account.
73 | * {@link https://www.vultr.com/api/#operation/list-vpcs} 74 | * @function listVpcs 75 | * @memberof vpcs 76 | * @instance 77 | */ 78 | exports.listVpcs = { 79 | url: '/vpcs', 80 | requestType: 'GET', 81 | apiKeyRequired: true, 82 | parameters: { 83 | per_page: { type: 'number' }, 84 | cursor: { type: 'string' } 85 | } 86 | } 87 | 88 | /** 89 | * Create a new vpc in a specified region.
90 | * {@link https://www.vultr.com/api/#operation/create-vpc} 91 | * @function createVpc 92 | * @memberof vpcs 93 | * @instance 94 | */ 95 | exports.createVpc = { 96 | url: '/vpcs', 97 | requestType: 'POST', 98 | apiKeyRequired: true, 99 | parameters: { 100 | region: { 101 | type: 'string', 102 | required: true 103 | }, 104 | description: { type: 'string' }, 105 | v4_subnet: { type: 'string' }, 106 | v4_subnet_mask: { type: 'number' } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /docs/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /test/api/object-storage.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | createObjectStorage: { 5 | cluster_id: '2' 6 | }, 7 | getObjectStorage: { 8 | 'object-storage-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | deleteObjectStorage: { 11 | 'object-storage-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 12 | }, 13 | updateObjectStorage: { 14 | 'object-storage-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 15 | label: 'my label' 16 | }, 17 | regenerateObjectStorageKeys: { 18 | 'object-storage-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 19 | } 20 | } 21 | 22 | const mockResponses = { 23 | listObjectStorages: { 24 | object_storages: [ 25 | { 26 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 27 | date_created: '2020-10-10T01:56:20+00:00', 28 | cluster_id: 2, 29 | region: 'ewr', 30 | label: 'my label', 31 | status: 'active', 32 | s3_hostname: 'ewr1.vultrobjects.com', 33 | s3_access_key: '81TPPS2573W0Y2A6', 34 | s3_secret_key: 'Bsb7oLAuN3ZgN9a4RiJsY34zEnTX2dt' 35 | } 36 | ], 37 | meta: { 38 | total: 1, 39 | links: { 40 | next: '', 41 | prev: '' 42 | } 43 | } 44 | }, 45 | createObjectStorage: { 46 | object_storage: { 47 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 48 | date_created: '2020-10-10T01:56:20+00:00', 49 | cluster_id: 2, 50 | region: 'ewr', 51 | location: 'New Jersey', 52 | label: 'api-obj-storage', 53 | status: 'pending', 54 | s3_hostname: '', 55 | s3_access_key: '', 56 | s3_secret_key: '' 57 | } 58 | }, 59 | getObjectStorage: { 60 | object_storage: { 61 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 62 | date_created: '2020-10-10T01:56:20+00:00', 63 | cluster_id: 2, 64 | region: 'ewr', 65 | label: 'api-obj-storage', 66 | status: 'active', 67 | s3_hostname: 'ewr1.vultrobjects.com', 68 | s3_access_key: '9I3YD23WDT6D78LE', 69 | s3_secret_key: 'Qv7P4Yy9Oh0YeAOHVM5DI1G2GsPJUJY5x' 70 | } 71 | }, 72 | regenerateObjectStorageKeys: { 73 | s3_credentials: { 74 | s3_hostname: 'ewr1.vultrobjects.com', 75 | s3_access_key: 'PR3VWWVBFW0IW', 76 | s3_secret_key: 'ZOJ7NIw0QACPlL62UefJnyMzAZ4SrBU' 77 | } 78 | }, 79 | getAllClusters: { 80 | clusters: [ 81 | { 82 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 83 | region: 'ewr', 84 | hostname: 'ewr1.vultrobjects.com', 85 | deploy: 'yes' 86 | } 87 | ], 88 | meta: { 89 | total: 1, 90 | links: { 91 | next: '', 92 | prev: '' 93 | } 94 | } 95 | } 96 | } 97 | 98 | util.createTestSuite('object-storage', mockParameters, mockResponses) 99 | -------------------------------------------------------------------------------- /src/api/users.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the users endpoints
3 | * {@link https://www.vultr.com/api/#tag/users} 4 | * @namespace users 5 | */ 6 | 7 | /** 8 | * Get information about the specified user.
9 | * {@link https://www.vultr.com/api/#operation/get-user} 10 | * @function getUser 11 | * @memberof users 12 | * @instance 13 | */ 14 | exports.getUser = { 15 | url: '/users/{user-id}', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'user-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Delete the specified user.
29 | * {@link https://www.vultr.com/api/#operation/delete-user} 30 | * @function deleteUser 31 | * @memberof users 32 | * @instance 33 | */ 34 | exports.deleteUser = { 35 | url: '/users/{user-id}', 36 | requestType: 'DELETE', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'user-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information for the specified user.
49 | * {@link https://www.vultr.com/api/#operation/update-user} 50 | * @function updateUser 51 | * @memberof users 52 | * @instance 53 | */ 54 | exports.updateUser = { 55 | url: '/users/{user-id}', 56 | requestType: 'PATCH', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'user-id': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | email: { type: 'string' }, 65 | name: { type: 'string' }, 66 | password: { type: 'string' }, 67 | api_enabled: { type: 'boolean' }, 68 | acls: { type: 'array' } 69 | } 70 | } 71 | 72 | /** 73 | * Get a list of all users on the account.
74 | * {@link https://www.vultr.com/api/#operation/list-users} 75 | * @function getUsers 76 | * @memberof users 77 | * @instance 78 | */ 79 | exports.getUsers = { 80 | url: '/users', 81 | requestType: 'GET', 82 | apiKeyRequired: true, 83 | parameters: { 84 | per_page: { type: 'string' }, 85 | cursor: { type: 'string' } 86 | } 87 | } 88 | 89 | /** 90 | * Create a new user on the account.
91 | * {@link https://www.vultr.com/api/#operation/create-user} 92 | * @function createUser 93 | * @memberof users 94 | * @instance 95 | */ 96 | exports.createUser = { 97 | url: '/users', 98 | requestType: 'POST', 99 | apiKeyRequired: true, 100 | parameters: { 101 | email: { 102 | type: 'string', 103 | required: true 104 | }, 105 | name: { 106 | type: 'string', 107 | required: true 108 | }, 109 | password: { 110 | type: 'string', 111 | required: true 112 | }, 113 | api_enabled: { type: 'boolean' }, 114 | acls: { type: 'array' } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /docs/account.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: account.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: account.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the account endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/account}
32 |  * @namespace account
33 |  */
34 | 
35 | /**
36 |  * Get your Vultr account, permissions, and billing information.<br>
37 |  * {@link https://www.vultr.com/api/#operation/get-account}
38 |  * @function getAccountInfo
39 |  * @memberof account
40 |  * @instance
41 |  */
42 | exports.getAccountInfo = {
43 |   url: '/account',
44 |   requestType: 'GET',
45 |   apiKeyRequired: true
46 | }
47 | 
48 |
49 |
50 | 51 | 52 | 53 | 54 |
55 | 56 | 59 | 60 |
61 | 62 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/api/startup-scripts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the startup scripts endpoints
3 | * {@link https://www.vultr.com/api/#tag/startup} 4 | * @namespace startupScripts 5 | */ 6 | 7 | /** 8 | * Get information for the specified startup script.
9 | * {@link https://www.vultr.com/api/#operation/get-startup-script} 10 | * @function getStartupScript 11 | * @memberof startupScripts 12 | * @instance 13 | */ 14 | exports.getStartupScript = { 15 | url: '/startup-scripts/{startup-id}', 16 | requestType: 'POST', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'startup-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Delete a specified startup script.
29 | * {@link https://www.vultr.com/api/#operation/delete-startup-script} 30 | * @function deleteStartupScript 31 | * @memberof startupScripts 32 | * @instance 33 | */ 34 | exports.deleteStartupScript = { 35 | url: '/startup-scripts/{startup-id}', 36 | requestType: 'DELETE', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'startup-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information for the specified startup script.
49 | * {@link https://www.vultr.com/api/#operation/update-startup-script} 50 | * @function updateStartupScript 51 | * @memberof startupScripts 52 | * @instance 53 | */ 54 | exports.updateStartupScript = { 55 | url: '/startup-scripts/{startup-id}', 56 | requestType: 'PATCH', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'startup-id': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | name: { type: 'string' }, 65 | script: { type: 'string' }, 66 | type: { type: 'string' } 67 | } 68 | } 69 | 70 | /** 71 | * List all startup scripts on the account.
72 | * {@link https://www.vultr.com/api/#operation/list-startup-scripts} 73 | * @function listStartupScripts 74 | * @memberof startupScripts 75 | * @instance 76 | */ 77 | exports.listStartupScripts = { 78 | url: '/startup-scripts', 79 | requestType: 'GET', 80 | apiKeyRequired: true, 81 | parameters: { 82 | per_page: { type: 'string' }, 83 | cursor: { type: 'string' } 84 | } 85 | } 86 | 87 | /** 88 | * Create a new startup script.
89 | * {@link https://www.vultr.com/api/#operation/create-startup-script} 90 | * @function createStartupScript 91 | * @memberof startupScripts 92 | * @instance 93 | */ 94 | exports.createStartupScript = { 95 | url: '/startup-scripts', 96 | requestType: 'POST', 97 | apiKeyRequired: true, 98 | parameters: { 99 | name: { 100 | type: 'string', 101 | required: true 102 | }, 103 | script: { 104 | type: 'string', 105 | required: true 106 | }, 107 | type: { type: 'string' } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /test/api/reserved-ips.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getReservedIp: { 5 | 'reserved-ip': 'cb676a46-66fd-4dfb-b839-443f2e6c0b604' 6 | }, 7 | deleteReservedIp: { 8 | 'reserved-ip': 'cb676a46-66fd-4dfb-b839-443f2e6c0b604' 9 | }, 10 | updateReservedIp: { 11 | 'reserved-ip': 'cb676a46-66fd-4dfb-b839-443f2e6c0b604', 12 | label: 'Example Label' 13 | }, 14 | createReservedIp: { 15 | region: 'ewr', 16 | ip_type: 'v4' 17 | }, 18 | attachReservedIp: { 19 | 'reserved-ip': 'cb676a46-66fd-4dfb-b839-443f2e6c0b604', 20 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 21 | }, 22 | detachReservedIp: { 23 | 'reserved-ip': 'cb676a46-66fd-4dfb-b839-443f2e6c0b604' 24 | }, 25 | convertInstanceIpToReservedIp: { 26 | ip_address: '127.0.0.1' 27 | } 28 | } 29 | 30 | const mockResponses = { 31 | getReservedIp: { 32 | reserved_ip: { 33 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b604', 34 | region: 'ewr', 35 | ip_type: 'v4', 36 | subnet: '140.82.12.241', 37 | subnet_size: 32, 38 | label: 'my label', 39 | instance_id: '' 40 | } 41 | }, 42 | listReservedIps: { 43 | reserved_ips: [ 44 | { 45 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 46 | region: 'ewr', 47 | ip_type: 'v4', 48 | subnet: '96.30.199.231', 49 | subnet_size: 32, 50 | label: 'my label', 51 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 52 | }, 53 | { 54 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 55 | region: 'ewr', 56 | ip_type: 'v6', 57 | subnet: '2001:19f0:5:5157::', 58 | subnet_size: 64, 59 | label: 'my label2', 60 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 61 | } 62 | ], 63 | meta: { 64 | total: 2, 65 | links: { 66 | next: '', 67 | prev: '' 68 | } 69 | } 70 | }, 71 | createReservedIp: { 72 | reserved_ip: { 73 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 74 | region: 'ewr', 75 | ip_type: 'v4', 76 | subnet: '140.82.12.241', 77 | subnet_size: 32, 78 | label: 'my label', 79 | instance_id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 80 | } 81 | }, 82 | updateReservedIp: { 83 | reserved_ip: { 84 | id: 'string', 85 | region: 'string', 86 | ip_type: 'string', 87 | subnet: 'string', 88 | subnet_size: 0, 89 | label: 'Example Label', 90 | instance_id: 'string' 91 | } 92 | }, 93 | convertInstanceIpToReservedIp: { 94 | reserved_ip: { 95 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 96 | region: 'ewr', 97 | ip_type: 'v4', 98 | subnet: '127.0.0.1', 99 | subnet_size: 64, 100 | label: 'my label', 101 | instance_id: '3f26dfe9-6a18-4f3d-a543-0cbca7a3e496' 102 | } 103 | } 104 | } 105 | 106 | util.createTestSuite('reserved-ips', mockParameters, mockResponses) 107 | -------------------------------------------------------------------------------- /docs/applications.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: applications.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: applications.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the application endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/application}
32 |  * @namespace applications
33 |  */
34 | 
35 | /**
36 |  * Get a list of all One-Click applications.<br>
37 |  * {@link https://www.vultr.com/api/#operation/list-applications}
38 |  * @function list
39 |  * @memberof applications
40 |  * @instance
41 |  */
42 | exports.listApplications = {
43 |   url: '/applications',
44 |   requestType: 'GET',
45 |   apiKeyRequired: true,
46 |   parameters: {
47 |     per_page: { type: 'number' },
48 |     cursor: { type: 'string' }
49 |   }
50 | }
51 | 
52 |
53 |
54 | 55 | 56 | 57 | 58 |
59 | 60 | 63 | 64 |
65 | 66 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /docs/operating-systems.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: operating-systems.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: operating-systems.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the operating system endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/os}
32 |  * @namespace operatingSystems
33 |  */
34 | 
35 | /**
36 |  * Get a list of all OS images available to install from Vultr.<br>
37 |  * {@link https://www.vultr.com/api/#operation/list-os}
38 |  * @function listImages
39 |  * @memberof operatingSystems
40 |  * @instance
41 |  */
42 | exports.listImages = {
43 |   url: '/os',
44 |   requestType: 'GET',
45 |   apiKeyRequired: true,
46 |   parameters: {
47 |     per_page: { type: 'string' },
48 |     cursor: { type: 'string' }
49 |   }
50 | }
51 | 
52 |
53 |
54 | 55 | 56 | 57 | 58 |
59 | 60 | 63 | 64 |
65 | 66 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: "Automatic Releaser" 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | check-commit: 13 | runs-on: ubuntu-latest 14 | outputs: 15 | msg_check: ${{ steps.check-msg.outputs.match }} 16 | steps: 17 | - name: Check Message 18 | id: check-msg 19 | run: | 20 | pattern="^Release v[0-9]+.[0-9]+.[0-9]+ #(minor|major|patch)$" 21 | if [[ "${{ github.event.head_commit.message }}" =~ ${pattern} ]]; then 22 | echo ::set-output name=match::true 23 | fi 24 | create-tag: 25 | runs-on: ubuntu-latest 26 | if: needs.check-commit.outputs.msg_check == 'true' 27 | needs: check-commit 28 | outputs: 29 | new_tag: ${{ steps.tagger.outputs.new_tag }} 30 | steps: 31 | - uses: actions/checkout@v4 32 | with: 33 | fetch-depth: '0' 34 | 35 | - name: Bump version and push tag 36 | id: tagger 37 | uses: anothrNick/github-tag-action@1.67.0 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | WITH_V: true 41 | DEFAULT_BUMP: "none" 42 | 43 | create-release: 44 | runs-on: ubuntu-latest 45 | needs: create-tag 46 | steps: 47 | - name: Checkout code 48 | uses: actions/checkout@v4 49 | 50 | - name: Create Release 51 | id: create_release 52 | uses: actions/create-release@v1 53 | env: 54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 55 | with: 56 | tag_name: ${{ needs.create-tag.outputs.new_tag }} 57 | release_name: ${{ needs.create-tag.outputs.new_tag }} 58 | draft: false 59 | prerelease: false 60 | 61 | releaser: 62 | runs-on: ubuntu-latest 63 | needs: create-release 64 | steps: 65 | - 66 | name: Checkout 67 | uses: actions/checkout@v4 68 | with: 69 | fetch-depth: 0 70 | 71 | - 72 | name: Setup node 73 | uses: actions/setup-node@v2 74 | with: 75 | node-version: '16' 76 | registry-url: 'https://registry.npmjs.org' 77 | 78 | - run: npm ci 79 | 80 | - run: npm run build 81 | 82 | - run: npm publish 83 | env: 84 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 85 | 86 | release: 87 | runs-on: ubuntu-latest 88 | needs: ["releaser", "create-tag"] 89 | name: Release Notification 90 | steps: 91 | - name: Get the version 92 | id: get_version 93 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 94 | - run: | 95 | echo "{\"text\":\"Vultr-Node : Release https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-tag.outputs.new_tag }} \"}" > mattermost.json 96 | - uses: mattermost/action-mattermost-notify@2.0.02.0.02.0.0 97 | with: 98 | MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} 99 | MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} 100 | MATTERMOST_ICON: ${{ secrets.MATTERMOST_ICON }} 101 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | const vultr = require('../src/index') 2 | const config = require('./config') 3 | 4 | describe('Vultr Instance', () => { 5 | it('initializes as an object', () => { 6 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 7 | expect(typeof vultrInstance).toEqual('object') 8 | }) 9 | 10 | it('requires an API key for endpoints that require an API key', () => { 11 | const vultrInstance = vultr.initialize() 12 | expect(() => { 13 | vultrInstance.account.getAccountInfo() 14 | }).toThrow(Error) 15 | }) 16 | 17 | it('requires parameters to be sent as an object', () => { 18 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 19 | expect(() => { 20 | vultrInstance.backups.listBackups(1) 21 | }).toThrow(Error) 22 | }) 23 | 24 | it('ignores parameters sent to endpoints that do not accept parameters', () => { 25 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 26 | expect( 27 | typeof vultrInstance.account.getAccountInfo({ 28 | param1: 'foo', 29 | param2: 'bar' 30 | }) 31 | ).toEqual('object') 32 | }) 33 | 34 | it('ignores extra parameters sent to endpoints that require parameters', () => { 35 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 36 | expect( 37 | typeof vultrInstance.bareMetal.createInstance({ 38 | region: 'ams', 39 | plan: 'vbm-4c-32gb', 40 | param1: 'foo', 41 | param2: 'bar' 42 | }) 43 | ).toEqual('object') 44 | }) 45 | 46 | it('requires all parameters', () => { 47 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 48 | expect(() => { 49 | vultrInstance.bareMetal.createInstance({}) 50 | }).toThrow(Error) 51 | }) 52 | 53 | it('allows number parameters to be passed in as a number or string', () => { 54 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 55 | expect( 56 | typeof vultrInstance.blockStorage.createStorage({ 57 | region: 'EWR', 58 | size_gb: '50' 59 | }) 60 | ).toEqual('object') 61 | }) 62 | 63 | it('requires number parameters to be contain only number characters', () => { 64 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 65 | expect(() => { 66 | vultrInstance.blockStorage.createStorage({ 67 | region: 'EWR', 68 | size_gb: '!@#$' 69 | }) 70 | }).toThrow(Error) 71 | }) 72 | 73 | it('requires required non-array and non-number parameters to match the specified parameter type', () => { 74 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 75 | expect(() => { 76 | vultrInstance.dns.createDomain({ domain: 1 }) 77 | }).toThrow(Error) 78 | }) 79 | 80 | it('requires required array parameters to be passed as an array', () => { 81 | const vultrInstance = vultr.initialize({ apiKey: config.apiKey }) 82 | expect(() => { 83 | vultrInstance.users.createUser({ 84 | email: 'test@test.com', 85 | name: 'test testerson', 86 | password: 'password', 87 | api_enabled: true, 88 | acls: 'manage_users' 89 | }) 90 | }).toThrow(Error) 91 | }) 92 | }) 93 | -------------------------------------------------------------------------------- /src/api/snapshots.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the snapshot endpoints
3 | * {@link https://www.vultr.com/api/#tag/snapshot} 4 | * @namespace snapshots 5 | */ 6 | 7 | /** 8 | * Delete the specified snapshot.
9 | * {@link https://www.vultr.com/api/#operation/delete-snapshot} 10 | * @function deleteSnapshot 11 | * @memberof snapshots 12 | * @instance 13 | */ 14 | exports.deleteSnapshot = { 15 | url: '/snapshots/{snapshot-id}', 16 | requestType: 'DELETE', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'snapshot-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Get information about the specified snapshot.
29 | * {@link https://www.vultr.com/api/#operation/get-snapshot} 30 | * @function getSnapshot 31 | * @memberof snapshots 32 | * @instance 33 | */ 34 | exports.getSnapshot = { 35 | url: '/snapshots/{snapshot-id}', 36 | requestType: 'GET', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'snapshot-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information for the specified snapshot.
49 | * {@link https://www.vultr.com/api/#operation/put-snapshots-snapshot-id} 50 | * @function updateSnapshot 51 | * @memberof snapshots 52 | * @instance 53 | */ 54 | exports.updateSnapshot = { 55 | url: '/snapshots/{snapshot-id}', 56 | requestType: 'PUT', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'snapshot-id': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | description: { 65 | type: 'string', 66 | required: true 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * List all snapshots on the account.
73 | * {@link https://www.vultr.com/api/#operation/list-snapshots} 74 | * @function listSnapshots 75 | * @memberof snapshots 76 | * @instance 77 | */ 78 | exports.listSnapshots = { 79 | url: '/snapshots', 80 | requestType: 'GET', 81 | apiKeyRequired: true, 82 | parameters: { 83 | per_page: { type: 'string' }, 84 | cursor: { type: 'string' }, 85 | description: { type: 'string' } 86 | } 87 | } 88 | 89 | /** 90 | * Create a new snapshot.
91 | * {@link https://www.vultr.com/api/#operation/create-snapshot} 92 | * @function createSnapshot 93 | * @memberof snapshots 94 | * @instance 95 | */ 96 | exports.createSnapshot = { 97 | url: '/snapshots', 98 | requestType: 'POST', 99 | apiKeyRequired: true, 100 | parameters: { 101 | instance_id: { 102 | type: 'string', 103 | required: true 104 | }, 105 | description: { type: 'string' } 106 | } 107 | } 108 | 109 | /** 110 | * Create a new snapshot from a specified URL.
111 | * {@link https://www.vultr.com/api/#operation/create-snapshot-create-from-url} 112 | * @function createSnapshotFromUrl 113 | * @memberof snapshots 114 | * @instance 115 | */ 116 | exports.createSnapshotFromUrl = { 117 | url: '/snapshots/create-from-url', 118 | requestType: 'POST', 119 | apiKeyRequired: true, 120 | parameters: { 121 | url: { 122 | type: 'string', 123 | required: true 124 | }, 125 | description: { type: 'string' } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/util.js: -------------------------------------------------------------------------------- 1 | exports.makeApiRequest = (config, endpoint, userParameters) => { 2 | const nf = require('node-fetch') 3 | const baseUrl = (config && config.baseUrl) || 'https://api.vultr.com/v2' 4 | let fetchUrl = `${baseUrl}${endpoint.url}` 5 | const options = { 6 | method: endpoint.requestType, 7 | headers: { 8 | Authorization: config && config.apiKey ? `Bearer ${config.apiKey}` : '' 9 | } 10 | } 11 | 12 | if (userParameters !== undefined) { 13 | const { requestType, parameters } = endpoint 14 | 15 | // All methods may have path parameters 16 | const pathParams = Object.keys(userParameters).filter( 17 | (key) => parameters[key].path 18 | ) 19 | 20 | if (pathParams.length) { 21 | pathParams.forEach((param) => { 22 | // Ex. '/bare-metals/{baremetal-id}/ipv4' becomes '/bare-metals/123456/ipv4' 23 | fetchUrl = fetchUrl.replace(`{${param}}`, userParameters[param]) 24 | }) 25 | } 26 | 27 | if (requestType === 'POST') { 28 | // POST requests will just send all data as JSON to the endpoint 29 | options.body = JSON.stringify(userParameters) 30 | options.headers['Content-Type'] = 'application/json' 31 | } else { 32 | if ( 33 | requestType === 'GET' || 34 | requestType === 'DELETE' || 35 | requestType === 'OPTIONS' 36 | ) { 37 | // GET and DELETE requests may have path parameters as well as query parameters 38 | const queryParams = Object.keys(userParameters) 39 | .filter((key) => !parameters[key].path) 40 | .map((key) => key + '=' + encodeURIComponent(userParameters[key])) 41 | .join('&') 42 | 43 | if (queryParams.length) { 44 | fetchUrl = `${fetchUrl}?${queryParams}` 45 | } 46 | } else if (requestType === 'PATCH' || requestType === 'PUT') { 47 | // PATCH and PUT requests may have path parameters and data as a JSON object 48 | const bodyParams = Object.keys(userParameters) 49 | .filter((key) => !parameters[key].path) 50 | .reduce( 51 | (newObj, key) => 52 | Object.assign(newObj, { [key]: userParameters[key] }), 53 | {} 54 | ) 55 | 56 | options.body = JSON.stringify(bodyParams) 57 | options.headers['Content-Type'] = 'application/json' 58 | } 59 | } 60 | } 61 | 62 | return nf(fetchUrl, options) 63 | .then((response) => { 64 | // The request was not successful 65 | if (!response.ok) { 66 | return response 67 | .json() 68 | .catch(() => { 69 | throw Error(response.statusText) 70 | }) 71 | .then((json) => { 72 | if (json.error) { 73 | throw Error(`${response.statusText}: ${json.error}`) 74 | } else { 75 | throw Error(response.statusText) 76 | } 77 | }) 78 | } 79 | 80 | const contentType = response.headers.get('content-type') 81 | 82 | // The request was successful, but does not return any data 83 | if (!contentType || !contentType.includes('application/json')) { 84 | return 85 | } 86 | 87 | // The request was successful and contains JSON data 88 | return response.json().then((responseJSON) => { 89 | return responseJSON 90 | }) 91 | }) 92 | .catch((err) => { 93 | return err 94 | }) 95 | } 96 | -------------------------------------------------------------------------------- /test/api/dns.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | createDomain: { 5 | domain: 'vultr.com' 6 | }, 7 | getDomain: { 8 | 'dns-domain': 'vultr.com' 9 | }, 10 | deleteDomain: { 11 | 'dns-domain': 'vultr.com' 12 | }, 13 | updateDomain: { 14 | 'dns-domain': 'vultr.com', 15 | dns_sec: 'enabled' 16 | }, 17 | getSoaInfo: { 18 | 'dns-domain': 'vultr.com' 19 | }, 20 | updateSoaInfo: { 21 | 'dns-domain': 'vultr.com' 22 | }, 23 | getDnsSecInfo: { 24 | 'dns-domain': 'vultr.com' 25 | }, 26 | createRecord: { 27 | 'dns-domain': 'vultr.com', 28 | name: 'www', 29 | type: 'A', 30 | data: '127.0.0.1' 31 | }, 32 | listRecords: { 33 | 'dns-domain': 'vultr.com' 34 | }, 35 | getRecord: { 36 | 'dns-domain': 'vultr.com', 37 | 'record-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 38 | }, 39 | updateRecord: { 40 | 'dns-domain': 'vultr.com', 41 | 'record-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 42 | }, 43 | deleteRecord: { 44 | 'dns-domain': 'vultr.com', 45 | 'record-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 46 | } 47 | } 48 | 49 | const mockResponses = { 50 | listDomains: { 51 | domains: [ 52 | { 53 | domain: 'vultr.com', 54 | date_created: '2020-10-10T01:56:20+00:00' 55 | } 56 | ], 57 | meta: { 58 | total: 1, 59 | links: { 60 | next: '', 61 | prev: '' 62 | } 63 | } 64 | }, 65 | createDomain: { 66 | domain: { 67 | domain: 'vultr.com', 68 | date_created: '2020-10-10T01:56:20+00:00' 69 | } 70 | }, 71 | getDomain: { 72 | domain: { 73 | domain: 'vultr.com', 74 | date_created: '2020-10-10T01:56:20+00:00', 75 | dns_sec: 'enabled' 76 | } 77 | }, 78 | updateDomain: { 79 | dns_sec: 'enabled' 80 | }, 81 | getSoaInfo: { 82 | dns_soa: { 83 | nsprimary: 'ns1.vultr.com', 84 | email: 'dnsadm@vultr.com' 85 | } 86 | }, 87 | getDnsSecInfo: { 88 | dns_sec: [ 89 | 'example.com IN DNSKEY 257 3 13 kRrxANp7YTGqVbaWtMy8hhsK0jcG4ajjICZKMb4fKv79Vx/RSn76vNjzIT7/Uo0BXil01Fk8RRQc4nWZctGJBA==', 90 | 'example.com IN DS 27933 13 1 2d9ac457e5c11a104e25d971d0a6254562bddde7', 91 | 'example.com IN DS 27933 13 2 8858e7b0dfb881280ce2ca1e0eafcd93d5b53687c21da284d4f8799ba82208a9' 92 | ] 93 | }, 94 | createRecord: { 95 | record: { 96 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 97 | type: 'A', 98 | name: 'www', 99 | data: '127.0.0.1', 100 | priority: 0, 101 | ttl: 300 102 | } 103 | }, 104 | listRecords: { 105 | records: [ 106 | { 107 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 108 | type: 'A', 109 | name: '', 110 | data: '127.0.0.1', 111 | priority: 0, 112 | ttl: 300 113 | } 114 | ], 115 | meta: { 116 | total: 1, 117 | links: { 118 | next: '', 119 | prev: '' 120 | } 121 | } 122 | }, 123 | getRecord: { 124 | record: { 125 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 126 | type: 'A', 127 | name: 'www', 128 | data: '127.0.0.1', 129 | priority: 0, 130 | ttl: 300 131 | } 132 | } 133 | } 134 | 135 | util.createTestSuite('dns', mockParameters, mockResponses) 136 | -------------------------------------------------------------------------------- /test/api/firewall.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | getGroup: { 5 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 6 | }, 7 | updateGroup: { 8 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 9 | description: 'my description' 10 | }, 11 | deleteGroup: { 12 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 13 | }, 14 | listRules: { 15 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 16 | }, 17 | createRules: { 18 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 19 | ip_type: 'v4', 20 | protocol: 'TCP', 21 | subnet: '127.0.0.1', 22 | subnet_size: '32' 23 | }, 24 | deleteRule: { 25 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 26 | 'firewall-rule-id': '1' 27 | }, 28 | getRule: { 29 | 'firewall-group-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 30 | 'firewall-rule-id': '1' 31 | } 32 | } 33 | 34 | const mockResponses = { 35 | listGroups: { 36 | firewall_groups: [ 37 | { 38 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 39 | description: 'my firewall group', 40 | date_created: '2020-10-10T01:56:20+00:00', 41 | date_modified: '2020-10-10T01:59:20+00:00', 42 | instance_count: 0, 43 | rule_count: 0, 44 | max_rule_count: 50 45 | } 46 | ], 47 | meta: { 48 | total: 1, 49 | links: { 50 | next: '', 51 | prev: '' 52 | } 53 | } 54 | }, 55 | createGroup: { 56 | firewall_group: { 57 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 58 | description: 'my firewall group', 59 | date_created: '2020-10-10T01:56:20+00:00', 60 | date_modified: '2020-10-10T01:56:20+00:00', 61 | instance_count: 0, 62 | rule_count: 0, 63 | max_rule_count: 50 64 | } 65 | }, 66 | getGroup: { 67 | firewall_group: { 68 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 69 | description: 'my firewall group', 70 | date_created: '2020-10-10T01:56:20+00:00', 71 | date_modified: '2020-10-10T01:56:20+00:00', 72 | instance_count: 0, 73 | rule_count: 0, 74 | max_rule_count: 50 75 | } 76 | }, 77 | listRules: { 78 | firewall_rules: [ 79 | { 80 | id: 1, 81 | ip_type: 'v4', 82 | action: 'accept', 83 | protocol: 'tcp', 84 | port: '80', 85 | subnet: '10.234.22.0', 86 | subnet_size: 24, 87 | source: '', 88 | notes: 'example' 89 | } 90 | ], 91 | meta: { 92 | total: 1, 93 | links: { 94 | next: '', 95 | prev: '' 96 | } 97 | } 98 | }, 99 | createRules: { 100 | firewall_rule: { 101 | id: 1, 102 | ip_type: 'v4', 103 | action: 'accept', 104 | protocol: 'tcp', 105 | port: '80', 106 | subnet: '10.234.22.0', 107 | subnet_size: 24, 108 | source: '', 109 | notes: 'example' 110 | } 111 | }, 112 | getRule: { 113 | firewall_rule: { 114 | id: 1, 115 | ip_type: 'v4', 116 | action: 'accept', 117 | protocol: 'tcp', 118 | port: '80', 119 | subnet: '10.234.22.0', 120 | subnet_size: 24, 121 | source: '', 122 | notes: 'example' 123 | } 124 | } 125 | } 126 | 127 | util.createTestSuite('firewall', mockParameters, mockResponses) 128 | -------------------------------------------------------------------------------- /docs/plans.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: plans.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: plans.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the plan endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/plans}
32 |  * @namespace plans
33 |  */
34 | 
35 | /**
36 |  * Get a list of allavailable Vultr instance plans.<br>
37 |  * {@link https://www.vultr.com/api/#operation/list-plans}
38 |  * @function listPlans
39 |  * @memberof plans
40 |  * @instance
41 |  */
42 | exports.listPlans = {
43 |   url: '/plans',
44 |   requestType: 'GET',
45 |   parameters: {
46 |     type: { type: 'string' },
47 |     os: { type: 'string' },
48 |     per_page: { type: 'string' },
49 |     cursor: { type: 'string' }
50 |   }
51 | }
52 | /**
53 |  * Get a list of all available Vultr bare metal plans.<br>
54 |  * {@link https://www.vultr.com/api/#operation/list-metal-plans}
55 |  * @function listBareMetalPlans
56 |  * @memberof plans
57 |  * @instance
58 |  */
59 | exports.listBareMetalPlans = {
60 |   url: '/plans-metal',
61 |   requestType: 'GET',
62 |   parameters: {
63 |     per_page: { type: 'string' },
64 |     cursor: { type: 'string' }
65 |   }
66 | }
67 | 
68 |
69 |
70 | 71 | 72 | 73 | 74 |
75 | 76 | 79 | 80 |
81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /docs/backups.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: backups.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: backups.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the backup endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/backup}
32 |  * @namespace backup
33 |  */
34 | 
35 | /**
36 |  * Get information about backups in your account.<br>
37 |  * {@link https://www.vultr.com/api/#operation/list-backups}
38 |  * @function list
39 |  * @memberof backup
40 |  * @instance
41 |  */
42 | exports.listBackups = {
43 |   url: '/backups',
44 |   requestType: 'GET',
45 |   apiKeyRequired: true,
46 |   parameters: {
47 |     instance_id: { type: 'string' },
48 |     per_page: { type: 'number' },
49 |     cursor: { type: 'string' }
50 |   }
51 | }
52 | 
53 | /**
54 |  * Get information for the specified backup.<br>
55 |  * {@link https://www.vultr.com/api/#operation/get-backup}
56 |  * @function get
57 |  * @memberof backup
58 |  * @instance
59 |  */
60 | exports.getBackup = {
61 |   url: '/backups/{backup-id}',
62 |   requestType: 'GET',
63 |   apiKeyRequired: true,
64 |   parameters: {
65 |     'backup-id': {
66 |       type: 'string',
67 |       path: true,
68 |       required: true
69 |     }
70 |   }
71 | }
72 | 
73 |
74 |
75 | 76 | 77 | 78 | 79 |
80 | 81 | 84 | 85 |
86 | 87 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /docs/regions.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: regions.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: regions.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Methods for interacting with the region endpoints<br>
31 |  * {@link https://www.vultr.com/api/#tag/region}
32 |  * @namespace regions
33 |  */
34 | 
35 | /**
36 |  * List all regions available at Vultr.<br>
37 |  * {@link https://www.vultr.com/api/#operation/list-regions}
38 |  * @function listRegions
39 |  * @memberof regions
40 |  * @instance
41 |  */
42 | exports.listRegions = {
43 |   url: '/regions',
44 |   requestType: 'GET',
45 |   parameters: {
46 |     per_page: { type: 'string' },
47 |     cursor: { type: 'string' }
48 |   }
49 | }
50 | 
51 | /**
52 |  * List all available plans in the specified region.<br>
53 |  * {@link https://www.vultr.com/api/#operation/list-available-compute-region}
54 |  * @function listAvailableComputeInRegion
55 |  * @memberof regions
56 |  * @instance
57 |  */
58 | exports.listAvailableComputeInRegion = {
59 |   url: '/regions/{region-id}/availability',
60 |   requestType: 'GET',
61 |   parameters: {
62 |     'region-id': {
63 |       type: 'string',
64 |       path: true,
65 |       required: true
66 |     },
67 |     type: { type: 'string' }
68 |   }
69 | }
70 | 
71 |
72 |
73 | 74 | 75 | 76 | 77 |
78 | 79 | 82 | 83 |
84 | 85 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/api/object-storage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the object storage endpoints
3 | * {@link https://www.vultr.com/api/#tag/s3} 4 | * @namespace objectStorage 5 | */ 6 | 7 | /** 8 | * List all object storage volumes on the account.
9 | * {@link https://www.vultr.com/api/#operation/list-object-storages} 10 | * @function listObjectStorages 11 | * @memberof objectStorage 12 | * @instance 13 | */ 14 | exports.listObjectStorages = { 15 | url: '/object-storage', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'string' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | 24 | /** 25 | * Create an object storage volume.
26 | * {@link https://www.vultr.com/api/#operation/create-object-storage} 27 | * @function 28 | * @memberof objectStorage 29 | * @instance 30 | */ 31 | exports.createObjectStorage = { 32 | url: '/object-storage', 33 | requestType: 'POST', 34 | apiKeyRequired: true, 35 | parameters: { 36 | cluster_id: { 37 | type: 'string', 38 | required: true 39 | }, 40 | label: { type: 'string' } 41 | } 42 | } 43 | 44 | /** 45 | * Get information about the specified object sotrage volume.
46 | * {@link https://www.vultr.com/api/#operation/get-object-storage} 47 | * @function getObjectStorage 48 | * @memberof objectStorage 49 | * @instance 50 | */ 51 | exports.getObjectStorage = { 52 | url: '/object-storage/{object-storage-id}', 53 | requestType: 'GET', 54 | apiKeyRequired: true, 55 | parameters: { 56 | 'object-storage-id': { 57 | type: 'string', 58 | path: true, 59 | required: true 60 | } 61 | } 62 | } 63 | 64 | /** 65 | * Delete an object storage volume.
66 | * {@link https://www.vultr.com/api/#operation/delete-object-storage} 67 | * @function deleteObjectStorage 68 | * @memberof objectStorage 69 | * @instance 70 | */ 71 | exports.deleteObjectStorage = { 72 | url: '/object-storage/{object-storage-id}', 73 | requestType: 'DELETE', 74 | apiKeyRequired: true, 75 | parameters: { 76 | 'object-storage-id': { 77 | type: 'string', 78 | path: true, 79 | required: true 80 | } 81 | } 82 | } 83 | 84 | /** 85 | * Update information for the specified object storage volume.
86 | * {@link https://www.vultr.com/api/#operation/update-object-storage} 87 | * @function updateObjectStorage 88 | * @memberof objectStorage 89 | * @instance 90 | */ 91 | exports.updateObjectStorage = { 92 | url: '/object-storage/{object-storage-id}', 93 | requestType: 'PUT', 94 | apiKeyRequired: true, 95 | parameters: { 96 | 'object-storage-id': { 97 | type: 'string', 98 | path: true, 99 | required: true 100 | }, 101 | label: { 102 | type: 'string', 103 | required: true 104 | } 105 | } 106 | } 107 | 108 | /** 109 | * Regenerate keys for the specified object storage volume.
110 | * {@link https://www.vultr.com/api/#operation/regenerate-object-storage-keys} 111 | * @function regenerateObjectStorageKeys 112 | * @memberof objectStorage 113 | * @instance 114 | */ 115 | exports.regenerateObjectStorageKeys = { 116 | url: '/object-storage/{object-storage-id}/regenerate-keys', 117 | requestType: 'POST', 118 | apiKeyRequired: true, 119 | parameters: { 120 | 'object-storage-id': { 121 | type: 'string', 122 | path: true, 123 | required: true 124 | } 125 | } 126 | } 127 | 128 | /** 129 | * Get a list of all object storage clusters.
130 | * {@link https://www.vultr.com/api/#operation/list-object-storage-clusters} 131 | * @function getAllClusters 132 | * @memberof objectStorage 133 | * @instance 134 | */ 135 | exports.getAllClusters = { 136 | url: '/object-storage/clusters', 137 | requestType: 'GET', 138 | apiKeyRequired: true, 139 | parameters: { 140 | per_page: { type: 'string' }, 141 | cursor: { type: 'string' } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/api/block-storage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the block storage endpoints
3 | * {@link https://www.vultr.com/api/#block} 4 | * @namespace blockStorage 5 | */ 6 | 7 | /** 8 | * List all block storage volumes in the account.
9 | * {@link https://www.vultr.com/api/#operation/list-blocks} 10 | * @function listStorages 11 | * @memberof blockStorage 12 | * @instance 13 | */ 14 | exports.listStorages = { 15 | url: '/blocks', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'string' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | 24 | /** 25 | Create a new block storage volume.
26 | * {@link https://www.vultr.com/api/#operation/create-block} 27 | * @function createStorage 28 | * @memberof blockStorage 29 | * @instance 30 | */ 31 | exports.createStorage = { 32 | url: '/blocks', 33 | requestType: 'POST', 34 | apiKeyRequired: true, 35 | parameters: { 36 | region: { 37 | type: 'string', 38 | required: true 39 | }, 40 | size_gb: { 41 | type: 'number', 42 | required: true 43 | }, 44 | label: { type: 'string' }, 45 | block_type: { type: 'string' } 46 | } 47 | } 48 | 49 | /** 50 | * Get information for a specified block storage volume.
51 | * {@link https://www.vultr.com/api/#operation/get-block} 52 | * @function getStorage 53 | * @memberof blockStorage 54 | * @instance 55 | */ 56 | exports.getStorage = { 57 | url: '/blocks/{block-id}', 58 | requestType: 'GET', 59 | apiKeyRequired: true, 60 | parameters: { 61 | 'block-id': { 62 | type: 'string', 63 | path: true, 64 | required: true 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * Delete the specified block storage volume.
71 | * {@link https://www.vultr.com/api/#operation/delete-block} 72 | * @function deleteStorage 73 | * @memberof blockStorage 74 | * @instance 75 | */ 76 | exports.deleteStorage = { 77 | url: '/blocks/{block-id}', 78 | requestType: 'DELETE', 79 | apiKeyRequired: true, 80 | parameters: { 81 | 'block-id': { 82 | type: 'string', 83 | path: true, 84 | required: true 85 | } 86 | } 87 | } 88 | 89 | /** 90 | * Update the specified block storage volume.
91 | * {@link https://www.vultr.com/api/#operation/update-block} 92 | * @function updateStorage 93 | * @memberof blockStorage 94 | * @instance 95 | */ 96 | exports.updateStorage = { 97 | url: '/blocks/{block-id}', 98 | requestType: 'PATCH', 99 | apiKeyRequired: true, 100 | parameters: { 101 | 'block-id': { 102 | type: 'string', 103 | path: true, 104 | required: true 105 | }, 106 | label: { type: 'string' }, 107 | size_gb: { type: 'number' } 108 | } 109 | } 110 | 111 | /** 112 | * Attach a specified block storage volume to an instance.
113 | * {@link https://www.vultr.com/api/#operation/attach-block} 114 | * @function attachStorage 115 | * @memberof blockStorage 116 | * @instance 117 | */ 118 | exports.attachStorage = { 119 | url: '/blocks/{block-id}/attach', 120 | requestType: 'POST', 121 | apiKeyRequired: true, 122 | parameters: { 123 | 'block-id': { 124 | type: 'string', 125 | path: true, 126 | required: true 127 | }, 128 | instance_id: { 129 | type: 'string', 130 | required: true 131 | }, 132 | live: { type: 'boolean' } 133 | } 134 | } 135 | 136 | /** 137 | * Detach a block storage volume.
138 | * {@link https://www.vultr.com/api/#operation/detach-block} 139 | * @function detachStorage 140 | * @memberof blockStorage 141 | * @instance 142 | */ 143 | exports.detachStorage = { 144 | url: '/blocks/{block-id}/detach', 145 | requestType: 'POST', 146 | apiKeyRequired: true, 147 | parameters: { 148 | 'block-id': { 149 | type: 'string', 150 | path: true, 151 | required: true 152 | }, 153 | live: { type: 'boolean' } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /test/util.js: -------------------------------------------------------------------------------- 1 | exports.createTestSuite = (specificationFile, mockParameters, mockResponse) => { 2 | const vultr = require('../src/index') 3 | const config = require('./config') 4 | const fetch = require('node-fetch') 5 | const specification = require(`../src/api/${specificationFile}`) 6 | const Headers = jest.requireActual('node-fetch').Headers 7 | const Response = jest.requireActual('node-fetch').Response 8 | const apiModule = specificationFile.replace(/-([a-z])/g, function (str) { 9 | return str[1].toUpperCase() 10 | }) 11 | const validRequestTypes = ['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'OPTIONS'] 12 | 13 | jest.mock('node-fetch', () => jest.fn()) 14 | 15 | describe(`${apiModule}`, () => { 16 | for (const key in specification) { 17 | describe(`${key}()`, () => { 18 | const endpoint = specification[key] 19 | const requiredParameters = {} 20 | 21 | if (endpoint.parameters !== undefined) { 22 | for (const parameter in endpoint.parameters) { 23 | if (endpoint.parameters[parameter].required) { 24 | requiredParameters[parameter] = endpoint.parameters[parameter] 25 | } 26 | } 27 | } 28 | 29 | it('has a valid request type', () => { 30 | expect(validRequestTypes.includes(endpoint.requestType)).toEqual(true) 31 | }) 32 | 33 | if (endpoint.apiKeyRequired) { 34 | it('requires an API key', () => { 35 | const vultrInstance = vultr.initialize() 36 | 37 | expect(() => { 38 | vultrInstance[apiModule][key]() 39 | }).toThrow(Error) 40 | }) 41 | } else { 42 | it('does not require an API key', () => { 43 | const vultrInstance = vultr.initialize() 44 | const data = mockResponse[key] 45 | const responseData = { 46 | ok: true, 47 | headers: new Headers({ 48 | 'Content-Type': data !== undefined ? 'application/json' : '' 49 | }) 50 | } 51 | 52 | fetch.mockResolvedValue( 53 | new Response(JSON.stringify(data), responseData) 54 | ) 55 | 56 | vultrInstance[apiModule][key]( 57 | (mockParameters && mockParameters[key]) || {} 58 | ).then((response) => { 59 | if (data !== undefined) { 60 | expect(response).toEqual(data) 61 | } else { 62 | expect(response).toEqual(undefined) 63 | } 64 | }) 65 | }) 66 | } 67 | 68 | if (Object.keys(requiredParameters).length > 0) { 69 | it('fails when required parameters are not set', () => { 70 | const vultrInstance = vultr.initialize( 71 | endpoint.apiKeyRequired ? { apiKey: config.apiKey } : {} 72 | ) 73 | 74 | expect(() => { 75 | vultrInstance[apiModule][key]() 76 | }).toThrow(Error) 77 | }) 78 | } 79 | 80 | it('successfully communicates with the API', () => { 81 | const vultrInstance = vultr.initialize( 82 | endpoint.apiKeyRequired ? { apiKey: config.apiKey } : {} 83 | ) 84 | const data = mockResponse[key] 85 | const responseData = { 86 | ok: true, 87 | headers: new Headers({ 88 | 'Content-Type': data !== undefined ? 'application/json' : '' 89 | }) 90 | } 91 | 92 | fetch.mockResolvedValue( 93 | new Response(JSON.stringify(data), responseData) 94 | ) 95 | 96 | vultrInstance[apiModule][key]( 97 | (mockParameters && mockParameters[key]) || {} 98 | ).then((response) => { 99 | if (data !== undefined) { 100 | expect(response).toEqual(data) 101 | } else { 102 | expect(response).toEqual(undefined) 103 | } 104 | }) 105 | }) 106 | }) 107 | } 108 | }) 109 | } 110 | -------------------------------------------------------------------------------- /src/api/vpc2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the vpc2 endpoints
3 | * {@link https://www.vultr.com/api/#tag/vpc2} 4 | * @namespace vpc2 5 | */ 6 | 7 | /** 8 | * Get information about the specified vpc2.
9 | * {@link https://www.vultr.com/api/#operation/get-vpc2} 10 | * @function getVpc 11 | * @memberof vpc2 12 | * @instance 13 | */ 14 | exports.getVpc = { 15 | url: '/vpc2/{vpc-id}', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'vpc-id': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Delete a specified vpc2.
29 | * {@link https://www.vultr.com/api/#operation/delete-vpc2} 30 | * @function deleteVpc 31 | * @memberof vpc2 32 | * @instance 33 | */ 34 | exports.deleteVpc = { 35 | url: '/vpc2/{vpc-id}', 36 | requestType: 'DELETE', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'vpc-id': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information on the specified vpc2.
49 | * {@link https://www.vultr.com/api/#operation/update-vpc2} 50 | * @function updateVpc 51 | * @memberof vpc2 52 | * @instance 53 | */ 54 | exports.updateVpc = { 55 | url: '/vpc2/{vpc-id}', 56 | requestType: 'PUT', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'vpc-id': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | description: { 65 | type: 'string', 66 | required: true 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * List all vpc2 on the account.
73 | * {@link https://www.vultr.com/api/#operation/list-vpc2} 74 | * @function listvpc2 75 | * @memberof vpc2 76 | * @instance 77 | */ 78 | exports.listVpcs = { 79 | url: '/vpc2', 80 | requestType: 'GET', 81 | apiKeyRequired: true, 82 | parameters: { 83 | per_page: { type: 'number' }, 84 | cursor: { type: 'string' } 85 | } 86 | } 87 | 88 | /** 89 | * Create a new vpc2 in a specified region.
90 | * {@link https://www.vultr.com/api/#operation/create-vpc2} 91 | * @function createVpc 92 | * @memberof vpc2 93 | * @instance 94 | */ 95 | exports.createVpc = { 96 | url: '/vpc2', 97 | requestType: 'POST', 98 | apiKeyRequired: true, 99 | parameters: { 100 | region: { 101 | type: 'string', 102 | required: true 103 | }, 104 | description: { type: 'string' }, 105 | ip_type: { type: 'string' }, 106 | ip_block: { type: 'string' }, 107 | prefix_length: { type: 'number' } 108 | } 109 | } 110 | 111 | /** 112 | * Get a list of nodes attached to a VPC 2.0 network.
113 | * {@link https://www.vultr.com/api/#tag/VPC2/operation/list-vpc2-nodes} 114 | * @function listVpcNodes 115 | * @memberof vpc2 116 | * @instance 117 | */ 118 | exports.listVpcNodes = { 119 | url: '/vpc2/{vpc-id}/nodes', 120 | requestType: 'GET', 121 | apiKeyRequired: true, 122 | parameters: { 123 | 'vpc-id': { 124 | type: 'string', 125 | path: true, 126 | required: true 127 | }, 128 | per_page: { type: 'number' }, 129 | cursor: { type: 'string' } 130 | } 131 | } 132 | 133 | /** 134 | * Attach nodes to a VPC 2.0 network
135 | * {@link https://www.vultr.com/api/#tag/VPC2/operation/attach-vpc2-nodes} 136 | * @function attachVpcNodes 137 | * @memberof vpc2 138 | * @instance 139 | */ 140 | exports.attachVpcNodes = { 141 | url: '/vpc2/{vpc-id}/nodes/attach', 142 | requestType: 'POST', 143 | apiKeyRequired: true, 144 | parameters: { 145 | 'vpc-id': { 146 | type: 'string', 147 | path: true, 148 | required: true 149 | }, 150 | nodes: { 151 | type: 'array', 152 | required: true 153 | } 154 | } 155 | } 156 | 157 | /** 158 | * Detach nodes from a VPC 2.0 network
159 | * {@link https://www.vultr.com/api/#tag/VPC2/operation/detach-vpc2-nodes} 160 | * @function detachVpcNodes 161 | * @memberof vpc2 162 | * @instance 163 | */ 164 | exports.detachVpcNodes = { 165 | url: '/vpc2/{vpc-id}/nodes/detach', 166 | requestType: 'POST', 167 | apiKeyRequired: true, 168 | parameters: { 169 | 'vpc-id': { 170 | type: 'string', 171 | path: true, 172 | required: true 173 | }, 174 | nodes: { 175 | type: 'array', 176 | required: true 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /docs/billing.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: billing.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: billing.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the billing endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/billing}
 32 |  * @namespace billing
 33 |  */
 34 | 
 35 | /**
 36 |  * Retrieves a list of all billing history on the current account.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/list-billing-history}
 38 |  * @function listHistory
 39 |  * @memberof billing
 40 |  * @instance
 41 |  */
 42 | exports.listHistory = {
 43 |   url: '/billing/history',
 44 |   requestType: 'GET',
 45 |   apiKeyRequired: true
 46 | }
 47 | 
 48 | /**
 49 |  * Retrieves a list of all billing invoices on the current account.<br>
 50 |  * {@link https://www.vultr.com/api/#operation/list-invoices}
 51 |  * @function listInvoices
 52 |  * @memberof billing
 53 |  * @instance
 54 |  */
 55 | exports.listInvoices = {
 56 |   url: '/billing/invoices',
 57 |   requestType: 'GET',
 58 |   apiKeyRequired: true
 59 | }
 60 | 
 61 | /**
 62 |  * Retrieves the invoice that matches the given invoice-id.<br>
 63 |  * {@link https://www.vultr.com/api/#operation/get-invoice}
 64 |  * @function getInvoice
 65 |  * @memberof billing
 66 |  * @instance
 67 |  */
 68 | exports.getInvoice = {
 69 |   url: '/billing/invoices/{invoice-id}',
 70 |   requestType: 'GET',
 71 |   apiKeyRequired: true,
 72 |   parameters: {
 73 |     'invoice-id': {
 74 |       type: 'string',
 75 |       path: true,
 76 |       required: true
 77 |     }
 78 |   }
 79 | }
 80 | 
 81 | /**
 82 |  * Retrieves items in the invoice that matches the given invoice-id.<br>
 83 |  * {@link https://www.vultr.com/api/#operation/get-invoice-items}
 84 |  * @function listInvoiceItems
 85 |  * @memberof billing
 86 |  * @instance
 87 |  */
 88 | exports.listInvoiceItems = {
 89 |   url: '/billing/invoices/{invoice-id}/items',
 90 |   requestType: 'GET',
 91 |   apiKeyRequired: true,
 92 |   parameters: {
 93 |     'invoice-id': {
 94 |       type: 'string',
 95 |       path: true,
 96 |       required: true
 97 |     }
 98 |   }
 99 | }
100 | 
101 |
102 |
103 | 104 | 105 | 106 | 107 |
108 | 109 | 112 | 113 |
114 | 115 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/api/reserved-ips.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the reserved IP endpoints
3 | * {@link https://www.vultr.com/api/#tag/reserved-ip} 4 | * @namespace reservedIps 5 | */ 6 | 7 | /** 8 | * Get information about the specified reserved IP address.
9 | * {@link https://www.vultr.com/api/#operation/get-reserved-ip} 10 | * @function getReservedIp 11 | * @memberof reservedIps 12 | * @instance 13 | */ 14 | exports.getReservedIp = { 15 | url: '/reserved-ips/{reserved-ip}', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | 'reserved-ip': { 20 | type: 'string', 21 | path: true, 22 | required: true 23 | } 24 | } 25 | } 26 | 27 | /** 28 | * Delete the specified reserved IP address.
29 | * {@link https://www.vultr.com/api/#operation/delete-reserved-ip} 30 | * @function deleteReservedIp 31 | * @memberof reservedIps 32 | * @instance 33 | */ 34 | exports.deleteReservedIp = { 35 | url: '/reserved-ips/{reserved-ip}', 36 | requestType: 'DELETE', 37 | apiKeyRequired: true, 38 | parameters: { 39 | 'reserved-ip': { 40 | type: 'string', 41 | path: true, 42 | required: true 43 | } 44 | } 45 | } 46 | 47 | /** 48 | * Update information on a Reserved IP.
49 | * {@link https://www.vultr.com/api/#operation/patch-reserved-ips-reserved-ip} 50 | * @function updateReservedIp 51 | * @memberof reservedIps 52 | * @instance 53 | */ 54 | exports.updateReservedIp = { 55 | url: '/reserved-ips/{reserved-ip}', 56 | requestType: 'PATCH', 57 | apiKeyRequired: true, 58 | parameters: { 59 | 'reserved-ip': { 60 | type: 'string', 61 | path: true, 62 | required: true 63 | }, 64 | label: { 65 | type: 'string', 66 | required: true 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * List all reserved IP addresses.
73 | * {@link https://www.vultr.com/api/#operation/list-reserved-ips} 74 | * @function listReservedIps 75 | * @memberof reservedIps 76 | * @instance 77 | */ 78 | exports.listReservedIps = { 79 | url: '/reserved-ips', 80 | requestType: 'GET', 81 | apiKeyRequired: true, 82 | parameters: { 83 | per_page: { type: 'string' }, 84 | cursor: { type: 'string' } 85 | } 86 | } 87 | 88 | /** 89 | * Create a reserved IP address.
90 | * {@link https://www.vultr.com/api/#operation/create-reserved-ip} 91 | * @function createReservedIp 92 | * @memberof reservedIps 93 | * @instance 94 | */ 95 | exports.createReservedIp = { 96 | url: '/reserved-ips', 97 | requestType: 'POST', 98 | apiKeyRequired: true, 99 | parameters: { 100 | region: { 101 | type: 'string', 102 | required: true 103 | }, 104 | ip_type: { 105 | type: 'string', 106 | required: true 107 | }, 108 | label: { type: 'string' } 109 | } 110 | } 111 | 112 | /** 113 | * Attach a reserved IP address to the specified instance.
114 | * {@link https://www.vultr.com/api/#operation/attach-reserved-ip} 115 | * @function attachReservedIp 116 | * @memberof reservedIps 117 | * @instance 118 | */ 119 | exports.attachReservedIp = { 120 | url: '/reserved-ips/{reserved-ip}/attach', 121 | requestType: 'POST', 122 | apiKeyRequired: true, 123 | parameters: { 124 | 'reserved-ip': { 125 | type: 'string', 126 | path: true, 127 | required: true 128 | }, 129 | instance_id: { 130 | type: 'string', 131 | required: true 132 | } 133 | } 134 | } 135 | 136 | /** 137 | * Detach a reserved IP address.
138 | * {@link https://www.vultr.com/api/#operation/detach-reserved-ip} 139 | * @function detachReservedIp 140 | * @memberof reservedIps 141 | * @instance 142 | */ 143 | exports.detachReservedIp = { 144 | url: '/reserved-ips/{reserved-ip}/detach', 145 | requestType: 'POST', 146 | apiKeyRequired: true, 147 | parameters: { 148 | 'reserved-ip': { 149 | type: 'string', 150 | path: true, 151 | required: true 152 | } 153 | } 154 | } 155 | 156 | /** 157 | * Convert the IP address of an existing instance into a reserved IP.
158 | * {@link https://www.vultr.com/api/#operation/convert-reserved-ip} 159 | * @function convertInstanceIpToReservedIp 160 | * @memberof reservedIps 161 | * @instance 162 | */ 163 | exports.convertInstanceIpToReservedIp = { 164 | url: '/reserved-ips/convert', 165 | requestType: 'POST', 166 | apiKeyRequired: true, 167 | parameters: { 168 | ip_address: { 169 | type: 'string', 170 | required: true 171 | }, 172 | label: { type: 'string' } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /docs/iso.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: iso.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: iso.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the ISO endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/iso}
 32 |  * @namespace iso
 33 |  */
 34 | 
 35 | /**
 36 |  * List all ISOs in the account.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/list-isos}
 38 |  * @function listIsos
 39 |  * @memberof iso
 40 |  * @instance
 41 |  */
 42 | exports.listIsos = {
 43 |   url: '/iso',
 44 |   requestType: 'GET',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     per_page: { type: 'string' },
 48 |     cursor: { type: 'string' }
 49 |   }
 50 | }
 51 | 
 52 | /**
 53 |  * Create a new ISO in the account from a URL.<br>
 54 |  * {@link https://www.vultr.com/api/#operation/create-iso}
 55 |  * @function createIso
 56 |  * @memberof iso
 57 |  * @instance
 58 |  */
 59 | exports.createIso = {
 60 |   url: '/iso',
 61 |   requestType: 'POST',
 62 |   apiKeyRequired: true,
 63 |   parameters: {
 64 |     url: {
 65 |       type: 'string',
 66 |       required: true
 67 |     }
 68 |   }
 69 | }
 70 | 
 71 | /**
 72 |  * Get information about the specified ISO.<br>
 73 |  * {@link https://www.vultr.com/api/#operation/iso-get}
 74 |  * @function getIso
 75 |  * @memberof iso
 76 |  * @instance
 77 |  */
 78 | exports.getIso = {
 79 |   url: '/iso/{iso-id}',
 80 |   requestType: 'POST',
 81 |   apiKeyRequired: true,
 82 |   parameters: {
 83 |     'iso-id': {
 84 |       type: 'string',
 85 |       path: true,
 86 |       required: true
 87 |     }
 88 |   }
 89 | }
 90 | 
 91 | /**
 92 |  * Delete the specified ISO from the account.<br>
 93 |  * {@link https://www.vultr.com/api/#operation/delete-iso}
 94 |  * @function deleteIso
 95 |  * @memberof iso
 96 |  * @instance
 97 |  */
 98 | exports.deleteIso = {
 99 |   url: '/iso/{iso-id}',
100 |   requestType: 'DELETE',
101 |   apiKeyRequired: true,
102 |   parameters: {
103 |     'iso-id': {
104 |       type: 'string',
105 |       path: true,
106 |       required: true
107 |     }
108 |   }
109 | }
110 | 
111 | /**
112 |  * List all Vultr public ISOs.<br>
113 |  * {@link https://www.vultr.com/api/#operation/list-public-isos}
114 |  * @function listPublicIsos
115 |  * @memberof iso
116 |  * @instance
117 |  */
118 | exports.listPublicIsos = {
119 |   url: '/iso-public',
120 |   requestType: 'GET'
121 | }
122 | 
123 |
124 |
125 | 126 | 127 | 128 | 129 |
130 | 131 | 134 | 135 |
136 | 137 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/account.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: account 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: account

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

account

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the account endpoints
41 | https://www.vultr.com/api/#tag/account
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

getAccountInfo()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | Get your Vultr account, permissions, and billing information.
124 | https://www.vultr.com/api/#operation/get-account 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |
205 | 206 |
207 | 208 | 209 | 210 | 211 |
212 | 213 | 216 | 217 |
218 | 219 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /docs/applications.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: applications 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: applications

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

applications

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the application endpoints
41 | https://www.vultr.com/api/#tag/application
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

list()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | Get a list of all One-Click applications.
124 | https://www.vultr.com/api/#operation/list-applications 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |
205 | 206 |
207 | 208 | 209 | 210 | 211 |
212 | 213 | 216 | 217 |
218 | 219 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /docs/operatingSystems.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: operatingSystems 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: operatingSystems

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

operatingSystems

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the operating system endpoints
41 | https://www.vultr.com/api/#tag/os
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

listImages()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | Get a list of all OS images available to install from Vultr.
124 | https://www.vultr.com/api/#operation/list-os 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |
205 | 206 |
207 | 208 | 209 | 210 | 211 |
212 | 213 | 216 | 217 |
218 | 219 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /docs/ssh-keys.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: ssh-keys.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: ssh-keys.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the snapshot endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/ssh}
 32 |  * @namespace sshKeys
 33 |  */
 34 | 
 35 | /**
 36 |  * Get information about a specified SSH key.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/get-ssh-key}
 38 |  * @function getSshKey
 39 |  * @memberof sshKeys
 40 |  * @instance
 41 |  */
 42 | exports.getSshKey = {
 43 |   url: '/ssh-keys/{ssh-key-id}',
 44 |   requestType: 'GET',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     'ssh-key-id': {
 48 |       type: 'string',
 49 |       path: true,
 50 |       required: true
 51 |     }
 52 |   }
 53 | }
 54 | 
 55 | /**
 56 |  * Update information for the specified SSH key.<br>
 57 |  * {@link https://www.vultr.com/api/#operation/update-ssh-key}
 58 |  * @function updateSshKey
 59 |  * @memberof sshKeys
 60 |  * @instance
 61 |  */
 62 | exports.updateSshKey = {
 63 |   url: '/ssh-keys/{ssh-key-id}',
 64 |   requestType: 'PATCH',
 65 |   apiKeyRequired: true,
 66 |   parameters: {
 67 |     'ssh-key-id': {
 68 |       type: 'string',
 69 |       path: true,
 70 |       required: true
 71 |     },
 72 |     name: { type: 'string' },
 73 |     ssh_key: { type: 'string' }
 74 |   }
 75 | }
 76 | 
 77 | /**
 78 |  * Delete the specified SSH key.<br>
 79 |  * {@link https://www.vultr.com/api/#operation/delete-ssh-key}
 80 |  * @function deleteSshKey
 81 |  * @memberof sshKeys
 82 |  * @instance
 83 |  */
 84 | exports.deleteSshKey = {
 85 |   url: '/ssh-keys/{ssh-key-id}',
 86 |   requestType: 'DELETE',
 87 |   apiKeyRequired: true,
 88 |   parameters: {
 89 |     'ssh-key-id': {
 90 |       type: 'string',
 91 |       path: true,
 92 |       required: true
 93 |     }
 94 |   }
 95 | }
 96 | 
 97 | /**
 98 |  * List all SSH keys on the account.<br>
 99 |  * {@link https://www.vultr.com/api/#operation/list-ssh-keys}
100 |  * @function listSshKeys
101 |  * @memberof sshKeys
102 |  * @instance
103 |  */
104 | exports.listSshKeys = {
105 |   url: '/ssh-keys',
106 |   requestType: 'GET',
107 |   apiKeyRequired: true,
108 |   parameters: {
109 |     per_page: { type: 'string' },
110 |     cursor: { type: 'string' }
111 |   }
112 | }
113 | 
114 | /**
115 |  * Create a new SSH key.<br>
116 |  * {@link https://www.vultr.com/api/#operation/create-ssh-key}
117 |  * @function createSshKey
118 |  * @memberof sshKeys
119 |  * @instance
120 |  */
121 | exports.createSshKey = {
122 |   url: '/ssh-keys',
123 |   requestType: 'POST',
124 |   apiKeyRequired: true,
125 |   parameters: {
126 |     name: { type: 'string' },
127 |     ssh_key: { type: 'string' }
128 |   }
129 | }
130 | 
131 |
132 |
133 | 134 | 135 | 136 | 137 |
138 | 139 | 142 | 143 |
144 | 145 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/vpcs.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: vpcs.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: vpcs.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the vpc endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/VPCs}
 32 |  * @namespace vpcs
 33 |  */
 34 | 
 35 | /**
 36 |  * Get information about the specified vpc.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/get-vpc}
 38 |  * @function getVpc
 39 |  * @memberof vpcs
 40 |  * @instance
 41 |  */
 42 | exports.getVpc = {
 43 |   url: '/vpcs/{vpc-id}',
 44 |   requestType: 'GET',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     'vpc-id': {
 48 |       type: 'string',
 49 |       path: true,
 50 |       required: true
 51 |     }
 52 |   }
 53 | }
 54 | 
 55 | /**
 56 |  * Delete a specified vpc.<br>
 57 |  * {@link https://www.vultr.com/api/#operation/delete-vpc}
 58 |  * @function deleteVpc
 59 |  * @memberof vpcs
 60 |  * @instance
 61 |  */
 62 | exports.deleteVpc = {
 63 |   url: '/vpcs/{vpc-id}',
 64 |   requestType: 'DELETE',
 65 |   apiKeyRequired: true,
 66 |   parameters: {
 67 |     'vpc-id': {
 68 |       type: 'string',
 69 |       path: true,
 70 |       required: true
 71 |     }
 72 |   }
 73 | }
 74 | 
 75 | /**
 76 |  * Update information on the specified vpc.<br>
 77 |  * {@link https://www.vultr.com/api/#operation/update-vpc}
 78 |  * @function updateVpc
 79 |  * @memberof vpcs
 80 |  * @instance
 81 |  */
 82 | exports.updateVpc = {
 83 |   url: '/vpcs/{vpc-id}',
 84 |   requestType: 'PUT',
 85 |   apiKeyRequired: true,
 86 |   parameters: {
 87 |     'vpc-id': {
 88 |       type: 'string',
 89 |       path: true,
 90 |       required: true
 91 |     },
 92 |     description: {
 93 |       type: 'string',
 94 |       required: true
 95 |     }
 96 |   }
 97 | }
 98 | 
 99 | /**
100 |  * List all vpcs on the account.<br>
101 |  * {@link https://www.vultr.com/api/#operation/list-vpcs}
102 |  * @function listVpcs
103 |  * @memberof vpcs
104 |  * @instance
105 |  */
106 | exports.listVpcs = {
107 |   url: '/vpcs',
108 |   requestType: 'GET',
109 |   apiKeyRequired: true,
110 |   parameters: {
111 |     per_page: { type: 'number' },
112 |     cursor: { type: 'string' }
113 |   }
114 | }
115 | 
116 | /**
117 |  * Create a new vpc in a specified region.<br>
118 |  * {@link https://www.vultr.com/api/#operation/create-vpc}
119 |  * @function createVpc
120 |  * @memberof vpcs
121 |  * @instance
122 |  */
123 | exports.createVpc = {
124 |   url: '/vpcs',
125 |   requestType: 'POST',
126 |   apiKeyRequired: true,
127 |   parameters: {
128 |     region: {
129 |       type: 'string',
130 |       required: true
131 |     },
132 |     description: { type: 'string' },
133 |     v4_subnet: { type: 'string' },
134 |     v4_subnet_mask: { type: 'number' }
135 |   }
136 | }
137 | 
138 |
139 |
140 | 141 | 142 | 143 | 144 |
145 | 146 | 149 | 150 |
151 | 152 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /docs/users.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: users.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: users.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the users endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/users}
 32 |  * @namespace users
 33 |  */
 34 | 
 35 | /**
 36 |  * Get information about the specified user.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/get-user}
 38 |  * @function getUser
 39 |  * @memberof users
 40 |  * @instance
 41 |  */
 42 | exports.getUser = {
 43 |   url: '/users/{user-id}',
 44 |   requestType: 'GET',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     'user-id': {
 48 |       type: 'string',
 49 |       path: true,
 50 |       required: true
 51 |     }
 52 |   }
 53 | }
 54 | 
 55 | /**
 56 |  * Delete the specified user.<br>
 57 |  * {@link https://www.vultr.com/api/#operation/delete-user}
 58 |  * @function deleteUser
 59 |  * @memberof users
 60 |  * @instance
 61 |  */
 62 | exports.deleteUser = {
 63 |   url: '/users/{user-id}',
 64 |   requestType: 'DELETE',
 65 |   apiKeyRequired: true,
 66 |   parameters: {
 67 |     'user-id': {
 68 |       type: 'string',
 69 |       path: true,
 70 |       required: true
 71 |     }
 72 |   }
 73 | }
 74 | 
 75 | /**
 76 |  * Update information for the specified user.<br>
 77 |  * {@link https://www.vultr.com/api/#operation/update-user}
 78 |  * @function updateUser
 79 |  * @memberof users
 80 |  * @instance
 81 |  */
 82 | exports.updateUser = {
 83 |   url: '/users/{user-id}',
 84 |   requestType: 'PATCH',
 85 |   apiKeyRequired: true,
 86 |   parameters: {
 87 |     'user-id': {
 88 |       type: 'string',
 89 |       path: true,
 90 |       required: true
 91 |     },
 92 |     email: { type: 'string' },
 93 |     name: { type: 'string' },
 94 |     password: { type: 'string' },
 95 |     api_enabled: { type: 'boolean' },
 96 |     acls: { type: 'array' }
 97 |   }
 98 | }
 99 | 
100 | /**
101 |  * Get a list of all users on the account.<br>
102 |  * {@link https://www.vultr.com/api/#operation/list-users}
103 |  * @function getUsers
104 |  * @memberof users
105 |  * @instance
106 |  */
107 | exports.getUsers = {
108 |   url: '/users',
109 |   requestType: 'GET',
110 |   apiKeyRequired: true,
111 |   parameters: {
112 |     per_page: { type: 'string' },
113 |     cursor: { type: 'string' }
114 |   }
115 | }
116 | 
117 | /**
118 |  * Create a new user on the account.<br>
119 |  * {@link https://www.vultr.com/api/#operation/create-user}
120 |  * @function createUser
121 |  * @memberof users
122 |  * @instance
123 |  */
124 | exports.createUser = {
125 |   url: '/users',
126 |   requestType: 'POST',
127 |   apiKeyRequired: true,
128 |   parameters: {
129 |     email: {
130 |       type: 'string',
131 |       required: true
132 |     },
133 |     name: {
134 |       type: 'string',
135 |       required: true
136 |     },
137 |     password: {
138 |       type: 'string',
139 |       required: true
140 |     },
141 |     api_enabled: { type: 'boolean' },
142 |     acls: { type: 'array' }
143 |   }
144 | }
145 | 
146 |
147 |
148 | 149 | 150 | 151 | 152 |
153 | 154 | 157 | 158 |
159 | 160 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 |

Automatic Releaser 47 | Code Coverage test 48 | npm version 49 | license

50 |

vultr-node

51 |

Official Vultr client node module.

52 |

Installation

53 |
npm install @vultr/vultr-node
 54 | 
55 |

Usage

56 |

Vultr uses a PAT (Personal Access Token) to interact/authenticate with the APIs. An API Key can be generated and acquired from the API menu in settings.

57 |

Initialize

58 |
const VultrNode = require('@vultr/vultr-node')
 59 | 
 60 | // Initialize the instance with your configuration
 61 | const vultr = VultrNode.initialize({
 62 |   apiKey: 'your-api-key-here',
 63 |   baseUrl: 'https://example.com', // Optional
 64 |   rateLimit: 600 // Optional
 65 | })
 66 | 
67 |

Calling Endpoints

68 |
// Call endpoints using Promises
 69 | vultr.account.getAccountInfo().then((response) => {
 70 |   console.log(response)
 71 | })
 72 | 
73 |

Versioning

74 |

This project follows SemVer for versioning. For the versions available, see the tags on this repository

75 |

Documentation

76 |

This implements Vultr API V2. For documentation on all endpoints, please visit https://www.vultr.com/api/. To use Vultr API V1, please use the version of the library on the V1 branch, or any version of this library before 2.0.0.

77 |

For documentation specific to this client please visit https://vultr.github.io/vultr-node

78 |

Contributing

79 |

Feel free to send pull requests our way! Please see the contributing guidelines.

80 |

License

81 |

This project is licensed under the MIT License - see the LICENSE file for details.

82 |

Authors

83 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 |
96 | 97 | 100 | 101 |
102 | 103 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /docs/startup-scripts.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: startup-scripts.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: startup-scripts.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the startup scripts endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/startup}
 32 |  * @namespace startupScripts
 33 |  */
 34 | 
 35 | /**
 36 |  * Get information for the specified startup script.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/get-startup-script}
 38 |  * @function getStartupScript
 39 |  * @memberof startupScripts
 40 |  * @instance
 41 |  */
 42 | exports.getStartupScript = {
 43 |   url: '/startup-scripts/{startup-id}',
 44 |   requestType: 'POST',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     'startup-id': {
 48 |       type: 'string',
 49 |       path: true,
 50 |       required: true
 51 |     }
 52 |   }
 53 | }
 54 | 
 55 | /**
 56 |  * Delete a specified startup script.<br>
 57 |  * {@link https://www.vultr.com/api/#operation/delete-startup-script}
 58 |  * @function deleteStartupScript
 59 |  * @memberof startupScripts
 60 |  * @instance
 61 |  */
 62 | exports.deleteStartupScript = {
 63 |   url: '/startup-scripts/{startup-id}',
 64 |   requestType: 'DELETE',
 65 |   apiKeyRequired: true,
 66 |   parameters: {
 67 |     'startup-id': {
 68 |       type: 'string',
 69 |       path: true,
 70 |       required: true
 71 |     }
 72 |   }
 73 | }
 74 | 
 75 | /**
 76 |  * Update information for the specified startup script.<br>
 77 |  * {@link https://www.vultr.com/api/#operation/update-startup-script}
 78 |  * @function updateStartupScript
 79 |  * @memberof startupScripts
 80 |  * @instance
 81 |  */
 82 | exports.updateStartupScript = {
 83 |   url: '/startup-scripts/{startup-id}',
 84 |   requestType: 'PATCH',
 85 |   apiKeyRequired: true,
 86 |   parameters: {
 87 |     'startup-id': {
 88 |       type: 'string',
 89 |       path: true,
 90 |       required: true
 91 |     },
 92 |     name: { type: 'string' },
 93 |     script: { type: 'string' },
 94 |     type: { type: 'string' }
 95 |   }
 96 | }
 97 | 
 98 | /**
 99 |  * List all startup scripts on the account.<br>
100 |  * {@link https://www.vultr.com/api/#operation/list-startup-scripts}
101 |  * @function listStartupScripts
102 |  * @memberof startupScripts
103 |  * @instance
104 |  */
105 | exports.listStartupScripts = {
106 |   url: '/startup-scripts',
107 |   requestType: 'GET',
108 |   apiKeyRequired: true,
109 |   parameters: {
110 |     per_page: { type: 'string' },
111 |     cursor: { type: 'string' }
112 |   }
113 | }
114 | 
115 | /**
116 |  * Create a new startup script.<br>
117 |  * {@link https://www.vultr.com/api/#operation/create-startup-script}
118 |  * @function createStartupScript
119 |  * @memberof startupScripts
120 |  * @instance
121 |  */
122 | exports.createStartupScript = {
123 |   url: '/startup-scripts',
124 |   requestType: 'POST',
125 |   apiKeyRequired: true,
126 |   parameters: {
127 |     name: {
128 |       type: 'string',
129 |       required: true
130 |     },
131 |     script: {
132 |       type: 'string',
133 |       required: true
134 |     },
135 |     type: { type: 'string' }
136 |   }
137 | }
138 | 
139 |
140 |
141 | 142 | 143 | 144 | 145 |
146 | 147 | 150 | 151 |
152 | 153 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /src/api/firewall.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Methods for interacting with the firewall endpoints
3 | * {@link https://www.vultr.com/api/#tag/firewall} 4 | * @namespace firewall 5 | */ 6 | 7 | /** 8 | * Get a list of all firewall groups.
9 | * {@link https://www.vultr.com/api/#operation/list-firewall-groups} 10 | * @function listGroups 11 | * @memberof firewall 12 | * @instance 13 | */ 14 | exports.listGroups = { 15 | url: '/firewalls', 16 | requestType: 'GET', 17 | apiKeyRequired: true, 18 | parameters: { 19 | per_page: { type: 'string' }, 20 | cursor: { type: 'string' } 21 | } 22 | } 23 | 24 | /** 25 | * Create a firewall group.
26 | * {@link https://www.vultr.com/api/#operation/create-firewall-group} 27 | * @function createGroup 28 | * @memberof firewall 29 | * @instance 30 | */ 31 | exports.createGroup = { 32 | url: '/firewalls', 33 | requestType: 'POST', 34 | apiKeyRequired: true, 35 | parameters: { 36 | description: { type: 'string' } 37 | } 38 | } 39 | 40 | /** 41 | * Get info about the specified firewall group.
42 | * {@link https://www.vultr.com/api/#operation/get-firewall-group} 43 | * @function getGroup 44 | * @memberof firewall 45 | * @instance 46 | */ 47 | exports.getGroup = { 48 | url: '/firewalls/{firewall-group-id}', 49 | requestType: 'GET', 50 | apiKeyRequired: true, 51 | 'firewall-group-id': { 52 | type: 'string', 53 | path: true, 54 | required: true 55 | } 56 | } 57 | 58 | /** 59 | * Update the specified firewall group with a new description.
60 | * {@link https://www.vultr.com/api/#operation/update-firewall-group} 61 | * @function updateGroup 62 | * @memberof firewall 63 | * @instance 64 | */ 65 | exports.updateGroup = { 66 | url: '/firewalls/{firewall-group-id}', 67 | requestType: 'PUT', 68 | apiKeyRequired: true, 69 | parameters: { 70 | 'firewall-group-id': { 71 | type: 'string', 72 | path: true, 73 | required: true 74 | }, 75 | description: { 76 | type: 'string', 77 | required: true 78 | } 79 | } 80 | } 81 | 82 | /** 83 | * Delete the specified firewall group.
84 | * {@link https://www.vultr.com/api/#operation/delete-firewall-group} 85 | * @function deleteGroup 86 | * @memberof firewall 87 | * @instance 88 | */ 89 | exports.deleteGroup = { 90 | url: '/firewalls/{firewall-group-id}', 91 | requestType: 'DELETE', 92 | apiKeyRequired: true, 93 | parameters: { 94 | 'firewall-group-id': { 95 | type: 'string', 96 | path: true, 97 | required: true 98 | } 99 | } 100 | } 101 | 102 | /** 103 | * List all rules for the specified firewall group.
104 | * {@link https://www.vultr.com/api/#operation/list-firewall-group-rules} 105 | * @function listRules 106 | * @memberof firewall 107 | * @instance 108 | */ 109 | exports.listRules = { 110 | url: '/firewalls/{firewall-group-id}/rules', 111 | requestType: 'GET', 112 | apiKeyRequired: true, 113 | parameters: { 114 | 'firewall-group-id': { 115 | type: 'string', 116 | path: true, 117 | required: true 118 | } 119 | } 120 | } 121 | 122 | /** 123 | * Create new rules in the specified firewall group.
124 | * {@link https://www.vultr.com/api/#operation/post-firewalls-firewall-group-id-rules} 125 | * @function createRules 126 | * @memberof firewall 127 | * @instance 128 | */ 129 | exports.createRules = { 130 | url: '/firewalls/{firewall-group-id}/rules', 131 | requestType: 'POST', 132 | apiKeyRequired: true, 133 | parameters: { 134 | 'firewall-group-id': { 135 | type: 'string', 136 | path: true, 137 | required: true 138 | }, 139 | ip_type: { 140 | type: 'string', 141 | required: true 142 | }, 143 | protocol: { 144 | type: 'string', 145 | required: true 146 | }, 147 | subnet: { 148 | type: 'string', 149 | required: true 150 | }, 151 | subnet_size: { 152 | type: 'string', 153 | required: true 154 | }, 155 | port: { type: 'string' }, 156 | source: { type: 'string' }, 157 | notes: { type: 'string' } 158 | } 159 | } 160 | 161 | /** 162 | * Delete the specified rule in the specified firewall group.
163 | * {@link https://www.vultr.com/api/#operation/delete-firewall-group-rule} 164 | * @function deleteRule 165 | * @memberof firewall 166 | * @instance 167 | */ 168 | exports.deleteRule = { 169 | url: '/firewalls/{firewall-group-id}/rules/{firewall-rule-id}', 170 | requestType: 'DELETE', 171 | apiKeyRequired: true, 172 | parameters: { 173 | 'firewall-group-id': { 174 | type: 'string', 175 | path: true, 176 | required: true 177 | }, 178 | 'firewall-rule-id': { 179 | type: 'string', 180 | path: true, 181 | required: true 182 | } 183 | } 184 | } 185 | 186 | /** 187 | * Get the specified rule from the specified firewall group.
188 | * {@link https://www.vultr.com/api/#operation/get-firewall-group-rule} 189 | * @function getRule 190 | * @memberof firewall 191 | * @instance 192 | */ 193 | exports.getRule = { 194 | url: '/firewalls/{firewall-group-id}/rules/{firewall-rule-id}', 195 | requestType: 'GET', 196 | apiKeyRequired: true, 197 | parameters: { 198 | 'firewall-group-id': { 199 | type: 'string', 200 | path: true, 201 | required: true 202 | }, 203 | 'firewall-rule-id': { 204 | type: 'string', 205 | path: true, 206 | required: true 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /docs/snapshots.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: snapshots.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: snapshots.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Methods for interacting with the snapshot endpoints<br>
 31 |  * {@link https://www.vultr.com/api/#tag/snapshot}
 32 |  * @namespace snapshots
 33 |  */
 34 | 
 35 | /**
 36 |  * Delete the specified snapshot.<br>
 37 |  * {@link https://www.vultr.com/api/#operation/delete-snapshot}
 38 |  * @function deleteSnapshot
 39 |  * @memberof snapshots
 40 |  * @instance
 41 |  */
 42 | exports.deleteSnapshot = {
 43 |   url: '/snapshots/{snapshot-id}',
 44 |   requestType: 'DELETE',
 45 |   apiKeyRequired: true,
 46 |   parameters: {
 47 |     'snapshot-id': {
 48 |       type: 'string',
 49 |       path: true,
 50 |       required: true
 51 |     }
 52 |   }
 53 | }
 54 | 
 55 | /**
 56 |  * Get information about the specified snapshot.<br>
 57 |  * {@link https://www.vultr.com/api/#operation/get-snapshot}
 58 |  * @function getSnapshot
 59 |  * @memberof snapshots
 60 |  * @instance
 61 |  */
 62 | exports.getSnapshot = {
 63 |   url: '/snapshots/{snapshot-id}',
 64 |   requestType: 'GET',
 65 |   apiKeyRequired: true,
 66 |   parameters: {
 67 |     'snapshot-id': {
 68 |       type: 'string',
 69 |       path: true,
 70 |       required: true
 71 |     }
 72 |   }
 73 | }
 74 | 
 75 | /**
 76 |  * Update information for the specified snapshot.<br>
 77 |  * {@link https://www.vultr.com/api/#operation/put-snapshots-snapshot-id}
 78 |  * @function updateSnapshot
 79 |  * @memberof snapshots
 80 |  * @instance
 81 |  */
 82 | exports.updateSnapshot = {
 83 |   url: '/snapshots/{snapshot-id}',
 84 |   requestType: 'PUT',
 85 |   apiKeyRequired: true,
 86 |   parameters: {
 87 |     'snapshot-id': {
 88 |       type: 'string',
 89 |       path: true,
 90 |       required: true
 91 |     },
 92 |     description: {
 93 |       type: 'string',
 94 |       required: true
 95 |     }
 96 |   }
 97 | }
 98 | 
 99 | /**
100 |  * List all snapshots on the account.<br>
101 |  * {@link https://www.vultr.com/api/#operation/list-snapshots}
102 |  * @function listSnapshots
103 |  * @memberof snapshots
104 |  * @instance
105 |  */
106 | exports.listSnapshots = {
107 |   url: '/snapshots',
108 |   requestType: 'GET',
109 |   apiKeyRequired: true,
110 |   parameters: {
111 |     per_page: { type: 'string' },
112 |     cursor: { type: 'string' },
113 |     description: { type: 'string' }
114 |   }
115 | }
116 | 
117 | /**
118 |  * Create a new snapshot.<br>
119 |  * {@link https://www.vultr.com/api/#operation/create-snapshot}
120 |  * @function createSnapshot
121 |  * @memberof snapshots
122 |  * @instance
123 |  */
124 | exports.createSnapshot = {
125 |   url: '/snapshots',
126 |   requestType: 'POST',
127 |   apiKeyRequired: true,
128 |   parameters: {
129 |     instance_id: {
130 |       type: 'string',
131 |       required: true
132 |     },
133 |     description: { type: 'string' }
134 |   }
135 | }
136 | 
137 | /**
138 |  * Create a new snapshot from a specified URL.<br>
139 |  * {@link https://www.vultr.com/api/#operation/create-snapshot-create-from-url}
140 |  * @function createSnapshotFromUrl
141 |  * @memberof snapshots
142 |  * @instance
143 |  */
144 | exports.createSnapshotFromUrl = {
145 |   url: '/snapshots/create-from-url',
146 |   requestType: 'POST',
147 |   apiKeyRequired: true,
148 |   parameters: {
149 |     url: {
150 |       type: 'string',
151 |       required: true
152 |     },
153 |     description: { type: 'string' }
154 |   }
155 | }
156 | 
157 |
158 |
159 | 160 | 161 | 162 | 163 |
164 | 165 | 168 | 169 |
170 | 171 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /docs/backup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: backup 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: backup

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

backup

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the backup endpoints
41 | https://www.vultr.com/api/#tag/backup
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

get()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | Get information for the specified backup.
124 | https://www.vultr.com/api/#operation/get-backup 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |

list()

205 | 206 | 207 | 208 | 209 | 210 | 211 |
212 | Get information about backups in your account.
213 | https://www.vultr.com/api/#operation/list-backups 214 |
215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 |
229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
Source:
256 |
259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 |
294 | 295 |
296 | 297 | 298 | 299 | 300 |
301 | 302 | 305 | 306 |
307 | 308 | 311 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /docs/plans.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: plans 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: plans

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

plans

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the plan endpoints
41 | https://www.vultr.com/api/#tag/plans
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

listBareMetalPlans()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | Get a list of all available Vultr bare metal plans.
124 | https://www.vultr.com/api/#operation/list-metal-plans 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |

listPlans()

205 | 206 | 207 | 208 | 209 | 210 | 211 |
212 | Get a list of allavailable Vultr instance plans.
213 | https://www.vultr.com/api/#operation/list-plans 214 |
215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 |
229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
Source:
256 |
259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 |
294 | 295 |
296 | 297 | 298 | 299 | 300 |
301 | 302 | 305 | 306 |
307 | 308 | 311 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /docs/regions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Namespace: regions 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Namespace: regions

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

regions

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 |
Methods for interacting with the region endpoints
41 | https://www.vultr.com/api/#tag/region
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
Source:
75 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

Methods

108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

listAvailableComputeInRegion()

116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | List all available plans in the specified region.
124 | https://www.vultr.com/api/#operation/list-available-compute-region 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
Source:
167 |
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |

listRegions()

205 | 206 | 207 | 208 | 209 | 210 | 211 |
212 | List all regions available at Vultr.
213 | https://www.vultr.com/api/#operation/list-regions 214 |
215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 |
229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
Source:
256 |
259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 |
294 | 295 |
296 | 297 | 298 | 299 | 300 |
301 | 302 | 305 | 306 |
307 | 308 | 311 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /test/api/load-balancers.test.js: -------------------------------------------------------------------------------- 1 | const util = require('../util') 2 | 3 | const mockParameters = { 4 | createLoadBalancer: { 5 | region: 'ewr' 6 | }, 7 | getLoadBalancer: { 8 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 9 | }, 10 | updateLoadBalancer: { 11 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 12 | }, 13 | deleteLoadBalancer: { 14 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 15 | }, 16 | listForwardingRules: { 17 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 18 | }, 19 | createForwardingRule: { 20 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 21 | frontend_protocol: 'http', 22 | frontend_port: '8080', 23 | backend_protocol: 'http', 24 | backend_port: '80' 25 | }, 26 | getForwardingRule: { 27 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 28 | 'forwarding-rule-id': 'd42585eb85b1f69d' 29 | }, 30 | deleteForwardingRule: { 31 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 32 | 'forwarding-rule-id': 'd42585eb85b1f69d' 33 | }, 34 | listFirewallRules: { 35 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60' 36 | }, 37 | getFirewallRule: { 38 | 'load-balancer-id': 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 39 | 'firewall-rule-id': 'asb123f2e6c0b60' 40 | } 41 | } 42 | 43 | const mockResponses = { 44 | listLoadBalancers: { 45 | load_balancers: [ 46 | { 47 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 48 | date_created: '2020-10-10T01:56:20+00:00', 49 | region: 'ewr', 50 | label: 'my-lb', 51 | status: 'active', 52 | ipv4: '149.28.32.7', 53 | ipv6: '2001:19f0:5:4973:ffff:ffff:ffff:ffff', 54 | generic_info: { 55 | balancing_algorithm: 'roundrobin', 56 | ssl_redirect: false, 57 | sticky_sessions: { 58 | cookie_name: '' 59 | }, 60 | proxy_protocol: false 61 | }, 62 | health_check: { 63 | protocol: 'http', 64 | port: 80, 65 | path: '/health', 66 | check_interval: 10, 67 | response_timeout: 5, 68 | unhealthy_threshold: 3, 69 | healthy_threshold: 3 70 | }, 71 | has_ssl: false, 72 | forwarding_rules: [ 73 | { 74 | id: '73d85156c2c3129d', 75 | frontend_protocol: 'http', 76 | frontend_port: 80, 77 | backend_protocol: 'http', 78 | backend_port: 80 79 | } 80 | ], 81 | instances: [] 82 | } 83 | ], 84 | meta: { 85 | total: 1, 86 | links: { 87 | next: '', 88 | prev: '' 89 | } 90 | } 91 | }, 92 | createLoadBalancer: { 93 | load_balancer: { 94 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 95 | date_created: '2020-10-10T01:56:20+00:00', 96 | region: 'ewr', 97 | label: 'my-lb', 98 | status: 'pending', 99 | ipv4: '', 100 | ipv6: '', 101 | generic_info: { 102 | balancing_algorithm: 'roundrobin', 103 | ssl_redirect: false, 104 | sticky_sessions: { 105 | cookie_name: '' 106 | }, 107 | proxy_protocol: false 108 | }, 109 | health_check: { 110 | protocol: 'http', 111 | port: 80, 112 | path: '/health', 113 | check_interval: 10, 114 | response_timeout: 5, 115 | unhealthy_threshold: 3, 116 | healthy_threshold: 3 117 | }, 118 | has_ssl: false, 119 | http2: false, 120 | nodes: 1, 121 | forwarding_rules: [ 122 | { 123 | id: '73d85156c2c3129d', 124 | frontend_protocol: 'http', 125 | frontend_port: 80, 126 | backend_protocol: 'http', 127 | backend_port: 80 128 | } 129 | ], 130 | instances: [] 131 | } 132 | }, 133 | getLoadBalancer: { 134 | load_balancer: { 135 | id: 'cb676a46-66fd-4dfb-b839-443f2e6c0b60', 136 | date_created: '2020-10-10T01:56:20+00:00', 137 | region: 'ewr', 138 | label: 'my-lb', 139 | status: 'active', 140 | ipv4: '149.28.32.7', 141 | ipv6: '2001:19f0:5:4973:ffff:ffff:ffff:ffff', 142 | generic_info: { 143 | balancing_algorithm: 'roundrobin', 144 | ssl_redirect: false, 145 | sticky_sessions: { 146 | cookie_name: '' 147 | }, 148 | proxy_protocol: false 149 | }, 150 | health_check: { 151 | protocol: 'http', 152 | port: 80, 153 | path: '/health', 154 | check_interval: 10, 155 | response_timeout: 5, 156 | unhealthy_threshold: 3, 157 | healthy_threshold: 3 158 | }, 159 | has_ssl: false, 160 | forwarding_rules: [ 161 | { 162 | id: '73d85156c2c3129d', 163 | frontend_protocol: 'http', 164 | frontend_port: 80, 165 | backend_protocol: 'http', 166 | backend_port: 80 167 | } 168 | ], 169 | instances: [] 170 | } 171 | }, 172 | listForwardingRules: { 173 | forwarding_rules: [ 174 | { 175 | id: '73d85156c2c3129d', 176 | frontend_protocol: 'http', 177 | frontend_port: 80, 178 | backend_protocol: 'http', 179 | backend_port: 80 180 | } 181 | ], 182 | meta: { 183 | total: 1, 184 | links: { 185 | next: '', 186 | prev: '' 187 | } 188 | } 189 | }, 190 | getForwardingRule: { 191 | forwarding_rule: { 192 | id: 'd42585eb85b1f69d', 193 | frontend_protocol: 'http', 194 | frontend_port: 8080, 195 | backend_protocol: 'http', 196 | backend_port: 80 197 | } 198 | }, 199 | listFirewallRules: { 200 | firewall_rules: [ 201 | { 202 | id: 'asb123f2e6c0b60', 203 | port: 80, 204 | source: '24.187.16.196/16', 205 | ip_type: 'v4' 206 | } 207 | ], 208 | meta: { 209 | total: 1, 210 | links: { 211 | next: '', 212 | prev: '' 213 | } 214 | } 215 | }, 216 | getFirewallRule: { 217 | firewall_rule: { 218 | id: 'asb123f2e6c0b60', 219 | port: 80, 220 | source: '24.187.16.196/16', 221 | ip_type: 'v4' 222 | } 223 | } 224 | } 225 | 226 | util.createTestSuite('load-balancers', mockParameters, mockResponses) 227 | --------------------------------------------------------------------------------