Skip to content

Commit

Permalink
V2.8.0 (#761)
Browse files Browse the repository at this point in the history
* Add user_scheme param for instances/bm

* Add support for HA Controlplanes on Kubernetes

* Add Dbaas Promote Read Replica endpoint

* VKE enable_firewall param

* Add Dbaas usage endpoint

* Instances filter by firewall_group_id
  • Loading branch information
AFatalErrror authored Nov 16, 2023
1 parent 1963153 commit d097a2a
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/api/bare-metal.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ exports.createInstance = {
attach_vpc2: { type: 'array' },
detach_vpc2: { type: 'array' },
enable_vpc2: { type: 'boolean' },
tags: { type: 'array' }
tags: { type: 'array' },
user_scheme: { type: 'string' }
}
}

Expand Down Expand Up @@ -109,7 +110,8 @@ exports.updateInstance = {
enable_ipv6: { type: 'boolean' },
attach_vpc2: { type: 'array' },
detach_vpc2: { type: 'array' },
enable_vpc2: { type: 'boolean' }
enable_vpc2: { type: 'boolean' },
user_scheme: { type: 'string' }
}
}

Expand Down
40 changes: 40 additions & 0 deletions src/api/databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ exports.deleteDatabase = {
}
}

/**
* Get disk, memory, and vCPU usage information for a Managed Database.<br>
* {@link https://www.vultr.com/api/#tag/managed-databases/operation/get-database-usage}
* @function usage
* @memberof databases
* @instance
*/
exports.usage = {
url: '/databases/{database-id}/usage',
requestType: 'GET',
apiKeyRequired: true,
parameters: {
'database-id': {
type: 'string',
path: true,
required: true
}
}
}

/**
* List all database users within the Managed Database.<br>
* {@link https://www.vultr.com/api/#operation/list-database-users}
Expand Down Expand Up @@ -554,6 +574,26 @@ exports.databaseAddReadReplica = {
}
}

/**
* Promote a read-only replica node to its own primary Managed Database.<br>
* {@link https://www.vultr.com/api/#tag/managed-databases/operation/database-promote-read-replica}
* @function databasePromoteReadReplica
* @memberof databases
* @instance
*/
exports.databasePromoteReadReplica = {
url: '/databases/{database-id}/promote-read-replica',
requestType: 'POST',
apiKeyRequired: true,
parameters: {
'database-id': {
type: 'string',
path: true,
required: true
}
}
}

/**
* Get backup information for the Managed Database.<br>
* {@link https://www.vultr.com/api/#operation/get-backup-information}
Expand Down
9 changes: 6 additions & 3 deletions src/api/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ exports.listInstances = {
tag: { type: 'string' },
label: { type: 'string' },
main_ip: { type: 'string' },
region: { type: 'string' }
region: { type: 'string' },
firewall_group_id: { type: 'string' }
}
}

Expand Down Expand Up @@ -68,7 +69,8 @@ exports.createInstance = {
firewall_group_id: { type: 'string' },
reserved_ipv4: { type: 'string' },
enable_vpc: { type: 'boolean' },
enable_vpc2: { type: 'boolean' }
enable_vpc2: { type: 'boolean' },
user_scheme: { type: 'string' }
}
}

Expand Down Expand Up @@ -126,7 +128,8 @@ exports.updateInstance = {
detach_vpc: { type: 'array' },
detach_vpc2: { type: 'array' },
enable_vpc: { type: 'boolean' },
enable_vpc2: { type: 'boolean' }
enable_vpc2: { type: 'boolean' },
user_scheme: { type: 'string' }
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/kubernetes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ exports.createKubernetesCluster = {
type: 'string',
required: true
},
ha_controlplanes: { type: 'boolean' },
enable_firewall: { type: 'boolean' },
node_pools: { type: 'array' }
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ exports.initialize = (config) => {
getDatabase: createRequestFunction(databases.getDatabase),
updateDatabase: createRequestFunction(databases.updateDatabase),
deleteDatabase: createRequestFunction(databases.deleteDatabase),
usage: createRequestFunction(databases.usage),
listDatabaseUsers: createRequestFunction(databases.listDatabaseUsers),
createDatabaseUser: createRequestFunction(databases.createDatabaseUser),
getDatabaseUser: createRequestFunction(databases.getDatabaseUser),
Expand All @@ -216,6 +217,9 @@ exports.initialize = (config) => {
databaseAddReadReplica: createRequestFunction(
databases.databaseAddReadReplica
),
databasePromoteReadReplica: createRequestFunction(
databases.databasePromoteReadReplica
),
getBackupInformation: createRequestFunction(
databases.getBackupInformation
),
Expand Down
12 changes: 8 additions & 4 deletions test/api/bare-metal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const mockResponses = {
mac_address: 2199756823533,
os_id: 186,
app_id: 3,
features: ['ipv6']
features: ['ipv6'],
user_scheme: 'root'
}
],
meta: {
Expand Down Expand Up @@ -125,7 +126,8 @@ const mockResponses = {
os_id: 186,
app_id: 3,
image_id: '',
features: ['ipv6']
features: ['ipv6'],
user_scheme: 'root'
}
},
getInstance: {
Expand All @@ -150,7 +152,8 @@ const mockResponses = {
tag: '',
os_id: 186,
app_id: 3,
features: ['ipv6']
features: ['ipv6'],
user_scheme: 'root'
}
},
updateInstance: {
Expand All @@ -176,7 +179,8 @@ const mockResponses = {
tags: ['Another tag'],
os_id: 186,
app_id: 3,
features: ['ipv6']
features: ['ipv6'],
user_scheme: 'root'
}
},
getInstanceIpv4Addresses: {
Expand Down
23 changes: 23 additions & 0 deletions test/api/databases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const mockParameters = {
deleteDatabase: {
'database-id': '999c4ed0-f2e4-4f2a-a951-de358ceb9ab5'
},
usage: {
'database-id': '999c4ed0-f2e4-4f2a-a951-de358ceb9ab5'
},
listDatabaseUsers: {
'database-id': '999c4ed0-f2e4-4f2a-a951-de358ceb9ab5'
},
Expand Down Expand Up @@ -87,6 +90,9 @@ const mockParameters = {
region: 'ewr',
label: 'new_read_replica_label'
},
databasePromoteReadReplica: {
'database-id': '999c4ed0-f2e4-4f2a-a951-de358ceb9ab5'
},
getBackupInformation: {
'database-id': '999c4ed0-f2e4-4f2a-a951-de358ceb9ab5'
},
Expand Down Expand Up @@ -329,6 +335,23 @@ const mockResponses = {
read_replicas: ['...']
}
},
usage: {
usage: {
disk: {
current_gb: 1.25,
max_gb: 55,
percentage: 2.27
},
memory: {
current_mb: 768,
max_mb: 2048,
percentage: 37.5
},
cpu: {
percentage: 4.65
}
}
},
listDatabaseUsers: {
users: [
{
Expand Down
12 changes: 8 additions & 4 deletions test/api/instances.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ const mockResponses = {
os_id: 362,
app_id: 0,
firewall_group_id: '',
features: ['ddos_protection', 'ipv6', 'auto_backups']
features: ['ddos_protection', 'ipv6', 'auto_backups'],
user_scheme: 'root'
}
],
meta: {
Expand Down Expand Up @@ -180,7 +181,8 @@ const mockResponses = {
app_id: 0,
firewall_group_id: '',
features: ['ddos_protection', 'ipv6', 'auto_backups'],
tags: ['a tag', 'another']
tags: ['a tag', 'another'],
user_scheme: 'root'
}
]
},
Expand Down Expand Up @@ -211,7 +213,8 @@ const mockResponses = {
os_id: 387,
app_id: 0,
firewall_group_id: '',
features: ['ddos_protection', 'ipv6', 'auto_backups']
features: ['ddos_protection', 'ipv6', 'auto_backups'],
user_scheme: 'root'
}
},
updateInstance: {
Expand Down Expand Up @@ -242,7 +245,8 @@ const mockResponses = {
app_id: 0,
firewall_group_id: '',
features: ['ddos_protection', 'ipv6', 'auto_backups'],
tags: ['a tag', 'another']
tags: ['a tag', 'another'],
user_scheme: 'root'
}
},
reinstallInstance: {
Expand Down
6 changes: 6 additions & 0 deletions test/api/kubernetes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const mockResponses = {
createKubernetesCluster: {
vke_cluster: {
id: '455dcd32-e621-48ee-a10e-0cb5f754e13e',
firewall_group_id: '',
label: 'vke',
date_created: '2021-07-07T22:57:01+00:00',
cluster_subnet: '10.244.0.0/16',
Expand All @@ -94,6 +95,7 @@ const mockResponses = {
version: 'v1.20.0+1',
region: 'lax',
status: 'pending',
ha_controlplanes: false,
node_pools: [
{
id: '11e4443a-f92a-46d6-94c8-61c1a1a7514e',
Expand Down Expand Up @@ -138,6 +140,7 @@ const mockResponses = {
version: 'v1.20.0+1',
region: 'ewr',
status: 'active',
ha_controlplanes: false,
node_pools: [
{
id: '74de1914-63ea-4a78-9da5-b7220063c701',
Expand Down Expand Up @@ -179,6 +182,7 @@ const mockResponses = {
version: 'v1.20.0+1',
region: 'lax',
status: 'active',
ha_controlplanes: false,
node_pools: [
{
id: '11e4443a-f92a-46d6-94c8-61c1a1a7514e',
Expand Down Expand Up @@ -221,6 +225,7 @@ const mockResponses = {
getKubernetesCluster: {
vke_cluster: {
id: '455dcd32-e621-48ee-a10e-0cb5f754e13e',
firewall_group_id: '',
label: 'vke',
date_created: '2021-07-07T22:57:01+00:00',
cluster_subnet: '10.244.0.0/16',
Expand All @@ -230,6 +235,7 @@ const mockResponses = {
version: 'v1.20.0+1',
region: 'lax',
status: 'active',
ha_controlplanes: false,
node_pools: [
{
id: '11e4443a-f92a-46d6-94c8-61c1a1a7514e',
Expand Down

0 comments on commit d097a2a

Please sign in to comment.