vanhecke/celmex/3.0.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/vanhecke/celmex is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with the same repo name found; no cached copy. Use another version.

Details

Cortex.Api.Xql

XQL: saved queries, available datasets, tenant quota counters, query execution (async start/poll), and lookup-dataset row management.

type alias Dataset =
{ datasetName : Maybe String
, type_ : Maybe String
, logUpdateType : Maybe String
, lastUpdated : Maybe Int
, totalDaysStored : Maybe Int
, hotRange : Maybe DatasetRange
, coldRange : Maybe DatasetRange
, totalSizeStored : Maybe Int
, averageDailySize : Maybe Int
, totalEvents : Maybe Int
, averageEventSize : Maybe Int
, ttl : Maybe Int
, defaultQueryTarget : Maybe String
}

A dataset available to XQL queries, with its retention ranges and size stats. The wire format uses Title Case Spaced keys ("Dataset Name", "Last Updated", "Total Events", etc.) — not snake_case. defaultQueryTarget is emitted as a string ("TRUE" / "FALSE"), not a boolean.

type alias DatasetRange =
{ from : Maybe Int
, to : Maybe Int
}

Epoch-millisecond from/to range inside Dataset.

type alias Library =
{ queriesCount : Maybe Int
, xqlQueries : List LibraryQuery
}

Saved-query library returned by getLibrary.

type alias LibraryQuery =
{ id : Maybe Int
, name : Maybe String
, description : Maybe String
, queryText : Maybe String
, createdAt : Maybe Int
, createdBy : Maybe String
, createdByPretty : Maybe String
, modifiedAt : Maybe Int
, modifiedBy : Maybe String
, modifiedByPretty : Maybe String
, queryMetadata : Maybe Value
, isPrivate : Maybe Bool
, labels : List String
}

A single saved XQL query inside the Library. The live wire format uses xql_query_name, xql_query, and xql_query_tags for the query name, body, and tags; OpenAPI-schema field names like name, query_text, and labels are accepted as fallbacks.

type alias Quota =
{ licenseQuota : Maybe Float
, additionalPurchasedQuota : Maybe Float
, usedQuota : Maybe Float
, dailyUsedQuota : Maybe Float
, evalQuota : Maybe Float
, totalDailyRunningQueries : Maybe Int
, totalDailyConcurrentRejectedQueries : Maybe Int
, currentConcurrentActiveQueries : Value
, currentConcurrentActiveQueriesCount : Maybe Int
, maxDailyConcurrentActiveQueryCount : Maybe Int
}

The Cortex tenant returns quota counters as JSON numbers that may carry a decimal component (e.g. 4015.0), even though the OpenAPI schema documents them as integers. We decode every quota field as Float so the values survive roundtripping through the typed decoder without integer coercion dropping the fractional part.

dailyUsedQuota is not listed in the OpenAPI schema but is returned by the API in practice — per CLAUDE.md we capture every field the response contains.

getDatasets : Request (List Dataset)

POST /public_api/v1/xql/get_datasets

POST /public_api/xql_library/get

POST /public_api/v1/xql/get_quota

= Pending
| Success
| Fail
| OtherStatus String

Status of an async XQL query. OtherStatus is a forward-compatibility escape hatch — the documented values are PENDING / SUCCESS / FAIL.

= Relative Int
| Range
{ from : Int
, to : Int
}

Time window for a query. Relative is a duration in epoch-milliseconds (e.g. Relative 86400000 = last 24 hours); Range is an absolute from/to epoch-millisecond window.

type alias StartQueryArgs =
{ query : String
, timeframe : Maybe Timeframe
, tenants : List String
}

Arguments to startQuery. tenants is only meaningful in MSSP multi-tenant deployments — leave it [] for a single-tenant query.

type alias GetResultsArgs =
{ queryId : String
, pendingFlag : Maybe Bool
, limit : Maybe Int
, format : Maybe String
}

Arguments to getQueryResults. pendingFlag = Just False makes the server block until the query completes (subject to the per-request HTTP timeout); the default Nothing / Just True returns whatever status the server has right now.

type alias QueryResults =
{ status : QueryStatus
, numberOfResults : Maybe Int
, queryCostCharged : Maybe Value
, remainingQuota : Maybe Float
, remainingYearlyQuota : Maybe Float
, data : List Value
, streamId : Maybe String
}

Typed decoding of a get_query_results response. data and streamId are flattened up out of the nested results sub-object for ergonomic access.

The wire format exposes the per-tenant cost map under query_cost_charged (not query_cost as the current OpenAPI revision documents) and includes a remaining_yearly_quota counter alongside the daily remaining_quota — both are captured here so the typed decoder doesn't silently drop real response fields.

type alias StreamArgs =
{ streamId : String
, isGzipCompressed : Maybe Bool
}

Arguments to getQueryResultsStream. The stream_id comes from a prior QueryResults whose result set exceeded the single-response limit.

startQuery : StartQueryArgs -> Request String

POST /public_api/v1/xql/start_xql_query — kicks off an XQL query and returns the query_id string to poll with getQueryResults.

getQueryResults : GetResultsArgs -> Request QueryResults

POST /public_api/v1/xql/get_query_results — fetches the status and (when ready) results for a previously-started query. If status = Pending, call again after a short delay; if results exceeded the single-response limit, continue fetching via getQueryResultsStream with the returned streamId.

getQueryResultsStream : StreamArgs -> Request Value

POST /public_api/v1/xql/get_query_results_stream — pulls the tail of a large result set. The response shape is not in the OpenAPI schema (the Cortex API sends it chunked, optionally gzipped) so we pass it through as raw JSON.

type alias LookupAddArgs =
{ datasetName : String
, keyFields : List String
, data : Value
}

Arguments to lookupsAddData. Each row in data should be an object mapping field names to string values (the lookup dataset schema enforces per-field types server-side). With keyFields = [] the server inserts only; with non-empty keyFields the server upserts using those fields as the identity.

data is Encode.Value because the lookup-dataset schema is user-defined per dataset; the SDK cannot constrain the shape ahead of time.

type alias LookupAddResult =
{ added : Maybe Int
, updated : Maybe Int
, skipped : Maybe Int
}

Counts returned by lookupsAddData.

type alias LookupGetArgs =
{ datasetName : String
, filters : List (List ( String, String ))
, limit : Maybe Int
}

Arguments to lookupsGetData. Each entry in filters is a full object of AND-ed (field, value) pairs; multiple entries OR together.

type alias LookupGetResult =
{ data : Maybe Value
, filterCount : Maybe Int
, totalCount : Maybe Int
}

Payload returned by lookupsGetData.

type alias LookupRemoveArgs =
{ datasetName : String
, filters : List ( String, String )
}

Arguments to lookupsRemoveData. filters is a single AND-ed filter object (not the list-of-objects shape that lookupsGetData uses).

type alias LookupRemoveResult =
{ deleted : Maybe Int }

Row-count returned by lookupsRemoveData.

lookupsAddData : LookupAddArgs -> Request LookupAddResult

POST /public_api/v1/xql/lookups/add_data — insert or upsert rows into a lookup dataset.

lookupsGetData : LookupGetArgs -> Request LookupGetResult

POST /public_api/v1/xql/lookups/get_data — query rows in a lookup dataset with optional AND/OR-ed filter objects.

lookupsRemoveData : LookupRemoveArgs -> Request LookupRemoveResult

POST /public_api/v1/xql/lookups/remove_data — delete rows in a lookup dataset matching the given filter object.

type alias LibraryInsertArgs =
{ xqlQueries : List LibraryInsertQuery
, override : Bool
, tags : List String
}

Arguments to libraryInsert. xqlQueries is the batch to insert or upsert. With override = False the server rejects any entry whose name already exists; with override = True it upserts. tags is an optional list of labels applied to every query in the batch.

type alias LibraryInsertQuery =
{ name : String
, query : String
}

One row in LibraryInsertArgs.xqlQueries. The SDK serialises name to xql_query_name and query to xql_query on the wire.

type alias LibraryInsertResult =
{ added : List String
, updated : List String
, errors : List LibraryInsertError
}

Outcome of a libraryInsert call. added and updated are the names of queries the server created or upserted; errors is the list of per-item rejections ({name, message} pairs the API returns as [name, message] two-element arrays).

type alias LibraryInsertError =
{ name : String
, message : String
}

One row in the LibraryInsertResult errors array — the offending query name and the server's human-readable rejection reason.

libraryInsert : LibraryInsertArgs -> Request LibraryInsertResult

POST /public_api/xql_library/insert — insert or upsert a batch of saved XQL queries.

= ByNames (List String)
| ByTags (List String)

Selector for libraryDelete. The API rejects any request that combines names and tags, so the SDK forces callers to pick one at compile time.

type alias LibraryDeleteArgs =
{ criteria : LibraryDeleteCriteria }

Arguments to libraryDelete.

type alias LibraryDeleteResult =
{ queriesCount : Int
, xqlQueryNames : List String
, errors : List Value
}

Outcome of a libraryDelete call. queriesCount is the number of saved queries the server removed; xqlQueryNames is the list of names it removed; errors is the list of free-form per-item failure objects the server flagged without aborting the batch.

libraryDelete : LibraryDeleteArgs -> Request LibraryDeleteResult

POST /public_api/xql_library/delete — remove saved XQL queries by name or by tag.