diff --git a/packages/clients/src/api/vpc/v2/api.gen.ts b/packages/clients/src/api/vpc/v2/api.gen.ts index 1da108334..ef1f4f321 100644 --- a/packages/clients/src/api/vpc/v2/api.gen.ts +++ b/packages/clients/src/api/vpc/v2/api.gen.ts @@ -19,6 +19,7 @@ import { unmarshalAddSubnetsResponse, unmarshalDeleteSubnetsResponse, unmarshalListPrivateNetworksResponse, + unmarshalListSubnetsResponse, unmarshalListVPCsResponse, unmarshalPrivateNetwork, unmarshalSetSubnetsResponse, @@ -39,6 +40,8 @@ import type { GetVPCRequest, ListPrivateNetworksRequest, ListPrivateNetworksResponse, + ListSubnetsRequest, + ListSubnetsResponse, ListVPCsRequest, ListVPCsResponse, MigrateZonalPrivateNetworksRequest, @@ -334,6 +337,30 @@ export class API extends ParentAPI { unmarshalVPC, ) + protected pageOfListSubnets = (request: Readonly = {}) => + this.client.fetch( + { + 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 = {}) => + 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 diff --git a/packages/clients/src/api/vpc/v2/index.gen.ts b/packages/clients/src/api/vpc/v2/index.gen.ts index 5649d9700..cdb6fbbaa 100644 --- a/packages/clients/src/api/vpc/v2/index.gen.ts +++ b/packages/clients/src/api/vpc/v2/index.gen.ts @@ -17,6 +17,9 @@ export type { ListPrivateNetworksRequest, ListPrivateNetworksRequestOrderBy, ListPrivateNetworksResponse, + ListSubnetsRequest, + ListSubnetsRequestOrderBy, + ListSubnetsResponse, ListVPCsRequest, ListVPCsRequestOrderBy, ListVPCsResponse, diff --git a/packages/clients/src/api/vpc/v2/marshalling.gen.ts b/packages/clients/src/api/vpc/v2/marshalling.gen.ts index 2a96028d7..f7949edf4 100644 --- a/packages/clients/src/api/vpc/v2/marshalling.gen.ts +++ b/packages/clients/src/api/vpc/v2/marshalling.gen.ts @@ -16,6 +16,7 @@ import type { DeleteSubnetsRequest, DeleteSubnetsResponse, ListPrivateNetworksResponse, + ListSubnetsResponse, ListVPCsResponse, MigrateZonalPrivateNetworksRequest, PrivateNetwork, @@ -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( diff --git a/packages/clients/src/api/vpc/v2/types.gen.ts b/packages/clients/src/api/vpc/v2/types.gen.ts index a26fe8396..7786314c1 100644 --- a/packages/clients/src/api/vpc/v2/types.gen.ts +++ b/packages/clients/src/api/vpc/v2/types.gen.ts @@ -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' @@ -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