Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/clients/src/api/ipam/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
ReleaseIPRequest,
Resource,
ResourceType,
Reverse,
Source,
UpdateIPRequest,
} from './types.gen'
Expand Down
27 changes: 27 additions & 0 deletions packages/clients/src/api/ipam/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
IP,
ListIPsResponse,
Resource,
Reverse,
Source,
UpdateIPRequest,
} from './types.gen'
Expand All @@ -31,6 +32,19 @@ const unmarshalResource = (data: unknown): Resource => {
} as Resource
}

const unmarshalReverse = (data: unknown): Reverse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Reverse' failed as data isn't a dictionary.`,
)
}

return {
address: data.address,
hostname: data.hostname,
} as Reverse
}

const unmarshalSource = (data: unknown): Source => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -60,6 +74,7 @@ export const unmarshalIP = (data: unknown): IP => {
projectId: data.project_id,
region: data.region,
resource: data.resource ? unmarshalResource(data.resource) : undefined,
reverses: unmarshalArrayOfObject(data.reverses, unmarshalReverse),
source: unmarshalSource(data.source),
tags: data.tags,
updatedAt: unmarshalDate(data.updated_at),
Expand Down Expand Up @@ -102,9 +117,21 @@ export const marshalBookIPRequest = (
tags: request.tags,
})

const marshalReverse = (
request: Reverse,
defaults: DefaultValues,
): Record<string, unknown> => ({
address: request.address,
hostname: request.hostname,
})

export const marshalUpdateIPRequest = (
request: UpdateIPRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
reverses:
request.reverses !== undefined
? request.reverses.map(elt => marshalReverse(elt, defaults))
: undefined,
tags: request.tags,
})
14 changes: 14 additions & 0 deletions packages/clients/src/api/ipam/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export interface Resource {
name?: string
}

export interface Reverse {
/** Reverse domain name. */
hostname: string
/** IP corresponding to the hostname. */
address?: string
}

export interface Source {
/**
* This source is global.
Expand Down Expand Up @@ -83,6 +90,8 @@ export interface IP {
resource?: Resource
/** Tags for the IP. */
tags: string[]
/** Array of reverses associated with the IP. */
reverses: Reverse[]
/** Region of the IP. */
region: Region
/** Zone of the IP, if zonal. */
Expand Down Expand Up @@ -214,4 +223,9 @@ export type UpdateIPRequest = {
ipId: string
/** Tags for the IP. */
tags?: string[]
/**
* Array of reverse domain names associated with an IP in the subnet of the
* current IP.
*/
reverses?: Reverse[]
}