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
27 changes: 27 additions & 0 deletions packages/clients/src/api/vpc/v2/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
unmarshalAddSubnetsResponse,
unmarshalDeleteSubnetsResponse,
unmarshalListPrivateNetworksResponse,
unmarshalListSubnetsResponse,
unmarshalListVPCsResponse,
unmarshalPrivateNetwork,
unmarshalSetSubnetsResponse,
Expand All @@ -39,6 +40,8 @@ import type {
GetVPCRequest,
ListPrivateNetworksRequest,
ListPrivateNetworksResponse,
ListSubnetsRequest,
ListSubnetsResponse,
ListVPCsRequest,
ListVPCsResponse,
MigrateZonalPrivateNetworksRequest,
Expand Down Expand Up @@ -334,6 +337,30 @@ export class API extends ParentAPI {
unmarshalVPC,
)

protected pageOfListSubnets = (request: Readonly<ListSubnetsRequest> = {}) =>
this.client.fetch<ListSubnetsResponse>(
{
method: 'GET',
path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/subnets`,
urlParams: urlParams(
['order_by', request.orderBy],
['organization_id', request.organizationId],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['project_id', request.projectId],
['subnet_ids', request.subnetIds],
['vpc_id', request.vpcId],
),
},
unmarshalListSubnetsResponse,
)

listSubnets = (request: Readonly<ListSubnetsRequest> = {}) =>
enrichForPagination('subnets', this.pageOfListSubnets, request)

/**
* Set the subnets of a Private Network. Set subnets for an existing Private
* Network. Note that the method is PUT and not PATCH. Any existing subnets
Expand Down
3 changes: 3 additions & 0 deletions packages/clients/src/api/vpc/v2/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export type {
ListPrivateNetworksRequest,
ListPrivateNetworksRequestOrderBy,
ListPrivateNetworksResponse,
ListSubnetsRequest,
ListSubnetsRequestOrderBy,
ListSubnetsResponse,
ListVPCsRequest,
ListVPCsRequestOrderBy,
ListVPCsResponse,
Expand Down
16 changes: 16 additions & 0 deletions packages/clients/src/api/vpc/v2/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
DeleteSubnetsRequest,
DeleteSubnetsResponse,
ListPrivateNetworksResponse,
ListSubnetsResponse,
ListVPCsResponse,
MigrateZonalPrivateNetworksRequest,
PrivateNetwork,
Expand Down Expand Up @@ -132,6 +133,21 @@ export const unmarshalListPrivateNetworksResponse = (
} as ListPrivateNetworksResponse
}

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

return {
subnets: unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
totalCount: data.total_count,
} as ListSubnetsResponse
}

export const unmarshalListVPCsResponse = (data: unknown): ListVPCsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down
22 changes: 22 additions & 0 deletions packages/clients/src/api/vpc/v2/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type ListPrivateNetworksRequestOrderBy =
| 'name_asc'
| 'name_desc'

export type ListSubnetsRequestOrderBy = 'created_at_asc' | 'created_at_desc'

export type ListVPCsRequestOrderBy =
| 'created_at_asc'
| 'created_at_desc'
Expand Down Expand Up @@ -254,6 +256,26 @@ export interface ListPrivateNetworksResponse {
totalCount: number
}

export type ListSubnetsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
orderBy?: ListSubnetsRequestOrderBy
page?: number
pageSize?: number
organizationId?: string
projectId?: string
subnetIds?: string[]
vpcId?: string
}

export interface ListSubnetsResponse {
subnets: Subnet[]
totalCount: number
}

export type ListVPCsRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down