Skip to content

Commit 01711a9

Browse files
authored
feat(ipam): allow for bulk IPs release (#1277)
1 parent 8dd882b commit 01711a9

File tree

7 files changed

+66
-0
lines changed

7 files changed

+66
-0
lines changed

packages/clients/src/api/ipam/v1/api.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import type { Region } from '../../../bridge'
1111
import {
1212
marshalBookIPRequest,
13+
marshalReleaseIPSetRequest,
1314
marshalUpdateIPRequest,
1415
unmarshalIP,
1516
unmarshalListIPsResponse,
@@ -21,6 +22,7 @@ import type {
2122
ListIPsRequest,
2223
ListIPsResponse,
2324
ReleaseIPRequest,
25+
ReleaseIPSetRequest,
2426
UpdateIPRequest,
2527
} from './types.gen'
2628

@@ -72,6 +74,16 @@ export class API extends ParentAPI {
7274
path: `/ipam/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/ips/${validatePathParam('ipId', request.ipId)}`,
7375
})
7476

77+
releaseIPSet = (request: Readonly<ReleaseIPSetRequest> = {}) =>
78+
this.client.fetch<void>({
79+
body: JSON.stringify(
80+
marshalReleaseIPSetRequest(request, this.client.settings),
81+
),
82+
headers: jsonContentHeaders,
83+
method: 'POST',
84+
path: `/ipam/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/ip-sets/release`,
85+
})
86+
7587
/**
7688
* Get an IP. Retrieve details of an existing IP, specified by its IP ID.
7789
*

packages/clients/src/api/ipam/v1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type {
99
ListIPsRequestOrderBy,
1010
ListIPsResponse,
1111
ReleaseIPRequest,
12+
ReleaseIPSetRequest,
1213
Resource,
1314
ResourceType,
1415
Reverse,

packages/clients/src/api/ipam/v1/marshalling.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
BookIPRequest,
1212
IP,
1313
ListIPsResponse,
14+
ReleaseIPSetRequest,
1415
Resource,
1516
Reverse,
1617
Source,
@@ -117,6 +118,13 @@ export const marshalBookIPRequest = (
117118
tags: request.tags,
118119
})
119120

121+
export const marshalReleaseIPSetRequest = (
122+
request: ReleaseIPSetRequest,
123+
defaults: DefaultValues,
124+
): Record<string, unknown> => ({
125+
ip_ids: request.ipIds,
126+
})
127+
120128
const marshalReverse = (
121129
request: Reverse,
122130
defaults: DefaultValues,

packages/clients/src/api/ipam/v1/types.gen.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ export type ReleaseIPRequest = {
226226
ipId: string
227227
}
228228

229+
export type ReleaseIPSetRequest = {
230+
/**
231+
* Region to target. If none is passed will use default region from the
232+
* config.
233+
*/
234+
region?: Region
235+
ipIds?: string[]
236+
}
237+
229238
export type UpdateIPRequest = {
230239
/**
231240
* Region to target. If none is passed will use default region from the

packages/clients/src/api/rdb/v1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type {
3939
DeleteReadReplicaRequest,
4040
DeleteSnapshotRequest,
4141
DeleteUserRequest,
42+
EncryptionAtRest,
4243
Endpoint,
4344
EndpointDirectAccessDetails,
4445
EndpointLoadBalancerDetails,

packages/clients/src/api/rdb/v1/marshalling.gen.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import type {
3434
DeleteInstanceACLRulesResponse,
3535
DeleteInstanceSettingsRequest,
3636
DeleteInstanceSettingsResponse,
37+
EncryptionAtRest,
3738
Endpoint,
3839
EndpointDirectAccessDetails,
3940
EndpointLoadBalancerDetails,
@@ -267,6 +268,18 @@ export const unmarshalBackupSchedule = (data: unknown): BackupSchedule => {
267268
} as BackupSchedule
268269
}
269270

271+
const unmarshalEncryptionAtRest = (data: unknown): EncryptionAtRest => {
272+
if (!isJSONObject(data)) {
273+
throw new TypeError(
274+
`Unmarshalling the type 'EncryptionAtRest' failed as data isn't a dictionary.`,
275+
)
276+
}
277+
278+
return {
279+
enabled: data.enabled,
280+
} as EncryptionAtRest
281+
}
282+
270283
const unmarshalInstanceSetting = (data: unknown): InstanceSetting => {
271284
if (!isJSONObject(data)) {
272285
throw new TypeError(
@@ -335,6 +348,9 @@ export const unmarshalInstance = (data: unknown): Instance => {
335348
? unmarshalBackupSchedule(data.backup_schedule)
336349
: undefined,
337350
createdAt: unmarshalDate(data.created_at),
351+
encryption: data.encryption
352+
? unmarshalEncryptionAtRest(data.encryption)
353+
: undefined,
338354
endpoint: data.endpoint ? unmarshalEndpoint(data.endpoint) : undefined,
339355
endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
340356
engine: data.engine,
@@ -1002,12 +1018,23 @@ export const marshalCreateInstanceFromSnapshotRequest = (
10021018
node_type: request.nodeType,
10031019
})
10041020

1021+
const marshalEncryptionAtRest = (
1022+
request: EncryptionAtRest,
1023+
defaults: DefaultValues,
1024+
): Record<string, unknown> => ({
1025+
enabled: request.enabled,
1026+
})
1027+
10051028
export const marshalCreateInstanceRequest = (
10061029
request: CreateInstanceRequest,
10071030
defaults: DefaultValues,
10081031
): Record<string, unknown> => ({
10091032
backup_same_region: request.backupSameRegion,
10101033
disable_backup: request.disableBackup,
1034+
encryption:
1035+
request.encryption !== undefined
1036+
? marshalEncryptionAtRest(request.encryption, defaults)
1037+
: undefined,
10111038
engine: request.engine,
10121039
init_endpoints:
10131040
request.initEndpoints !== undefined

packages/clients/src/api/rdb/v1/types.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ export interface BackupSchedule {
294294
nextRunAt?: Date
295295
}
296296

297+
export interface EncryptionAtRest {
298+
enabled: boolean
299+
}
300+
297301
export interface InstanceSetting {
298302
name: string
299303
value: string
@@ -554,6 +558,8 @@ export interface Instance {
554558
backupSameRegion: boolean
555559
/** List of Database Instance maintenance events. */
556560
maintenances: Maintenance[]
561+
/** Encryption at rest settings for your Database Instance. */
562+
encryption?: EncryptionAtRest
557563
}
558564

559565
export interface NodeType {
@@ -820,6 +826,8 @@ export type CreateInstanceRequest = {
820826
* the Database Instance.
821827
*/
822828
backupSameRegion: boolean
829+
/** Encryption at rest settings for your Database Instance. */
830+
encryption?: EncryptionAtRest
823831
}
824832

825833
export type CreateReadReplicaEndpointRequest = {

0 commit comments

Comments
 (0)