Skip to content

Commit adf09e2

Browse files
authored
feat(ipam): allow publicly to set a custom reverse on their ip (#1077)
1 parent 1127301 commit adf09e2

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type {
1111
ReleaseIPRequest,
1212
Resource,
1313
ResourceType,
14+
Reverse,
1415
Source,
1516
UpdateIPRequest,
1617
} from './types.gen'

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
IP,
1313
ListIPsResponse,
1414
Resource,
15+
Reverse,
1516
Source,
1617
UpdateIPRequest,
1718
} from './types.gen'
@@ -31,6 +32,19 @@ const unmarshalResource = (data: unknown): Resource => {
3132
} as Resource
3233
}
3334

35+
const unmarshalReverse = (data: unknown): Reverse => {
36+
if (!isJSONObject(data)) {
37+
throw new TypeError(
38+
`Unmarshalling the type 'Reverse' failed as data isn't a dictionary.`,
39+
)
40+
}
41+
42+
return {
43+
address: data.address,
44+
hostname: data.hostname,
45+
} as Reverse
46+
}
47+
3448
const unmarshalSource = (data: unknown): Source => {
3549
if (!isJSONObject(data)) {
3650
throw new TypeError(
@@ -60,6 +74,7 @@ export const unmarshalIP = (data: unknown): IP => {
6074
projectId: data.project_id,
6175
region: data.region,
6276
resource: data.resource ? unmarshalResource(data.resource) : undefined,
77+
reverses: unmarshalArrayOfObject(data.reverses, unmarshalReverse),
6378
source: unmarshalSource(data.source),
6479
tags: data.tags,
6580
updatedAt: unmarshalDate(data.updated_at),
@@ -102,9 +117,21 @@ export const marshalBookIPRequest = (
102117
tags: request.tags,
103118
})
104119

120+
const marshalReverse = (
121+
request: Reverse,
122+
defaults: DefaultValues,
123+
): Record<string, unknown> => ({
124+
address: request.address,
125+
hostname: request.hostname,
126+
})
127+
105128
export const marshalUpdateIPRequest = (
106129
request: UpdateIPRequest,
107130
defaults: DefaultValues,
108131
): Record<string, unknown> => ({
132+
reverses:
133+
request.reverses !== undefined
134+
? request.reverses.map(elt => marshalReverse(elt, defaults))
135+
: undefined,
109136
tags: request.tags,
110137
})

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ export interface Resource {
4040
name?: string
4141
}
4242

43+
export interface Reverse {
44+
/** Reverse domain name. */
45+
hostname: string
46+
/** IP corresponding to the hostname. */
47+
address?: string
48+
}
49+
4350
export interface Source {
4451
/**
4552
* This source is global.
@@ -83,6 +90,8 @@ export interface IP {
8390
resource?: Resource
8491
/** Tags for the IP. */
8592
tags: string[]
93+
/** Array of reverses associated with the IP. */
94+
reverses: Reverse[]
8695
/** Region of the IP. */
8796
region: Region
8897
/** Zone of the IP, if zonal. */
@@ -214,4 +223,9 @@ export type UpdateIPRequest = {
214223
ipId: string
215224
/** Tags for the IP. */
216225
tags?: string[]
226+
/**
227+
* Array of reverse domain names associated with an IP in the subnet of the
228+
* current IP.
229+
*/
230+
reverses?: Reverse[]
217231
}

0 commit comments

Comments
 (0)