diff --git a/OMICRON_VERSION b/OMICRON_VERSION index 0b3abfd8b..229e577a3 100644 --- a/OMICRON_VERSION +++ b/OMICRON_VERSION @@ -1 +1 @@ -19e9f75ba5fe26df6ac3ada2f3a3bb8fa032186c +a9d9f1e1a17736aecc8d644c8d8c6174c1a5bc14 diff --git a/app/api/__generated__/Api.ts b/app/api/__generated__/Api.ts index 2580835b4..fd23132f0 100644 --- a/app/api/__generated__/Api.ts +++ b/app/api/__generated__/Api.ts @@ -151,6 +151,16 @@ export type AddressLotResultsPage = { nextPage?: string | null } +/** + * An address lot and associated blocks resulting from viewing an address lot. + */ +export type AddressLotViewResponse = { + /** The address lot blocks. */ + blocks: AddressLotBlock[] + /** The address lot. */ + lot: AddressLot +} + /** * Describes the scope of affinity for the purposes of co-location. */ @@ -3067,14 +3077,19 @@ export type Timeseries = { fields: Record; points: Points } * * A table is the result of an OxQL query. It contains a name, usually the name of the timeseries schema from which the data is derived, and any number of timeseries, which contain the actual data. */ -export type Table = { name: string; timeseries: Record } +export type OxqlTable = { + /** The name of the table. */ + name: string + /** The set of timeseries in the table, ordered by key. */ + timeseries: Timeseries[] +} /** * The result of a successful OxQL query. */ export type OxqlQueryResult = { /** Tables resulting from the query, each containing timeseries. */ - tables: Table[] + tables: OxqlTable[] } /** @@ -6111,6 +6126,10 @@ export interface NetworkingAddressLotListQueryParams { sortBy?: NameOrIdSortMode } +export interface NetworkingAddressLotViewPathParams { + addressLot: NameOrId +} + export interface NetworkingAddressLotDeletePathParams { addressLot: NameOrId } @@ -9377,6 +9396,19 @@ export class Api extends HttpClient { ...params, }) }, + /** + * Fetch address lot + */ + networkingAddressLotView: ( + { path }: { path: NetworkingAddressLotViewPathParams }, + params: FetchParams = {} + ) => { + return this.request({ + path: `/v1/system/networking/address-lot/${path.addressLot}`, + method: 'GET', + ...params, + }) + }, /** * Delete address lot */ diff --git a/app/api/__generated__/OMICRON_VERSION b/app/api/__generated__/OMICRON_VERSION index d769fd800..c089538b0 100644 --- a/app/api/__generated__/OMICRON_VERSION +++ b/app/api/__generated__/OMICRON_VERSION @@ -1,2 +1,2 @@ # generated file. do not update manually. see docs/update-pinned-api.md -19e9f75ba5fe26df6ac3ada2f3a3bb8fa032186c +a9d9f1e1a17736aecc8d644c8d8c6174c1a5bc14 diff --git a/app/api/__generated__/msw-handlers.ts b/app/api/__generated__/msw-handlers.ts index a1a593469..49e3afd79 100644 --- a/app/api/__generated__/msw-handlers.ts +++ b/app/api/__generated__/msw-handlers.ts @@ -1243,6 +1243,12 @@ export interface MSWHandlers { req: Request cookies: Record }) => Promisable> + /** `GET /v1/system/networking/address-lot/:addressLot` */ + networkingAddressLotView: (params: { + path: Api.NetworkingAddressLotViewPathParams + req: Request + cookies: Record + }) => Promisable> /** `DELETE /v1/system/networking/address-lot/:addressLot` */ networkingAddressLotDelete: (params: { path: Api.NetworkingAddressLotDeletePathParams @@ -2876,6 +2882,14 @@ export function makeHandlers(handlers: MSWHandlers): HttpHandler[] { '/v1/system/networking/address-lot', handler(handlers['networkingAddressLotCreate'], null, schema.AddressLotCreate) ), + http.get( + '/v1/system/networking/address-lot/:addressLot', + handler( + handlers['networkingAddressLotView'], + schema.NetworkingAddressLotViewParams, + null + ) + ), http.delete( '/v1/system/networking/address-lot/:addressLot', handler( diff --git a/app/api/__generated__/validate.ts b/app/api/__generated__/validate.ts index aa341271a..80b9ba073 100644 --- a/app/api/__generated__/validate.ts +++ b/app/api/__generated__/validate.ts @@ -166,6 +166,14 @@ export const AddressLotResultsPage = z.preprocess( z.object({ items: AddressLot.array(), nextPage: z.string().nullable().optional() }) ) +/** + * An address lot and associated blocks resulting from viewing an address lot. + */ +export const AddressLotViewResponse = z.preprocess( + processResponseBody, + z.object({ blocks: AddressLotBlock.array(), lot: AddressLot }) +) + /** * Describes the scope of affinity for the purposes of co-location. */ @@ -2845,9 +2853,9 @@ export const Timeseries = z.preprocess( * * A table is the result of an OxQL query. It contains a name, usually the name of the timeseries schema from which the data is derived, and any number of timeseries, which contain the actual data. */ -export const Table = z.preprocess( +export const OxqlTable = z.preprocess( processResponseBody, - z.object({ name: z.string(), timeseries: z.record(z.string(), Timeseries) }) + z.object({ name: z.string(), timeseries: Timeseries.array() }) ) /** @@ -2855,7 +2863,7 @@ export const Table = z.preprocess( */ export const OxqlQueryResult = z.preprocess( processResponseBody, - z.object({ tables: Table.array() }) + z.object({ tables: OxqlTable.array() }) ) /** @@ -6698,6 +6706,16 @@ export const NetworkingAddressLotCreateParams = z.preprocess( }) ) +export const NetworkingAddressLotViewParams = z.preprocess( + processResponseBody, + z.object({ + path: z.object({ + addressLot: NameOrId, + }), + query: z.object({}), + }) +) + export const NetworkingAddressLotDeleteParams = z.preprocess( processResponseBody, z.object({ diff --git a/app/api/window.ts b/app/api/window.ts index 72e910e41..c48bccbdb 100644 --- a/app/api/window.ts +++ b/app/api/window.ts @@ -47,7 +47,7 @@ if (typeof window !== 'undefined') { const data = handleResult(result).tables logHeading(data.length + ' timeseries returned') for (const table of data) { - for (const ts of Object.values(table.timeseries)) { + for (const ts of table.timeseries) { const fields = Object.entries(ts.fields) .map(([k, v]) => `${k}: ${v.value}`) .join(', ') diff --git a/app/components/oxql-metrics/util.spec.ts b/app/components/oxql-metrics/util.spec.ts index 1545f3e2f..9d2f2121b 100644 --- a/app/components/oxql-metrics/util.spec.ts +++ b/app/components/oxql-metrics/util.spec.ts @@ -131,8 +131,8 @@ const utilizationQueryResult1: OxqlQueryResult = { tables: [ { name: 'virtual_machine:vcpu_usage', - timeseries: { - '16671618930358432507': { + timeseries: [ + { fields: { vcpuId: { type: 'u32', @@ -157,12 +157,12 @@ const utilizationQueryResult1: OxqlQueryResult = { ], }, }, - }, + ], }, ], } -const timeseries1 = utilizationQueryResult1.tables[0].timeseries['16671618930358432507'] +const timeseries1 = utilizationQueryResult1.tables[0].timeseries[0] test('sumValues', () => { expect(sumValues([], 0)).toEqual([]) diff --git a/app/components/oxql-metrics/util.ts b/app/components/oxql-metrics/util.ts index 267a6e3ea..266dfec6c 100644 --- a/app/components/oxql-metrics/util.ts +++ b/app/components/oxql-metrics/util.ts @@ -129,7 +129,7 @@ export const sumValues = (timeseries: Timeseries[], arrLen: number): (number | n export const composeOxqlData = (data: OxqlQueryResult | undefined) => { let timeseriesCount = 0 if (!data) return { chartData: [], timeseriesCount } - const timeseriesData = Object.values(data.tables[0].timeseries) + const timeseriesData = data.tables[0].timeseries timeseriesCount = timeseriesData.length if (!timeseriesCount) return { chartData: [], timeseriesCount } // Extract timestamps (all series should have the same timestamps) diff --git a/mock-api/msw/handlers.ts b/mock-api/msw/handlers.ts index af6ad59fe..b6e077819 100644 --- a/mock-api/msw/handlers.ts +++ b/mock-api/msw/handlers.ts @@ -1633,7 +1633,7 @@ export const handlers = makeHandlers({ // we use other-project to test certain response cases if (query.project === 'other-project') { // 1. return only one data point - const points = Object.values(data.tables[0].timeseries)[0].points + const points = data.tables[0].timeseries[0].points if (body.query.includes('state == "run"')) { points.timestamps = points.timestamps.slice(0, 2) points.values = points.values.slice(0, 2) @@ -1836,6 +1836,7 @@ export const handlers = makeHandlers({ networkingAddressLotCreate: NotImplemented, networkingAddressLotDelete: NotImplemented, networkingAddressLotList: NotImplemented, + networkingAddressLotView: NotImplemented, networkingAllowListUpdate: NotImplemented, networkingAllowListView: NotImplemented, networkingBfdDisable: NotImplemented, diff --git a/mock-api/oxql-metrics.ts b/mock-api/oxql-metrics.ts index b63e165f2..ff54ac353 100644 --- a/mock-api/oxql-metrics.ts +++ b/mock-api/oxql-metrics.ts @@ -286,9 +286,9 @@ export const getMockOxqlInstanceData = ( tables: [ { name: name, - timeseries: { + timeseries: [ // This is a fake metric ID - '10607783231231666598': { + { fields: { instanceId: { type: 'uuid', @@ -309,7 +309,7 @@ export const getMockOxqlInstanceData = ( ], }, }, - }, + ], }, ], })