Skip to content

DB resources

Every /db/* endpoint is a DbResource subclass. The base class below defines the whole CRUD surface; each concrete resource only declares ENDPOINT, NAME, PRODUCTS and METHODS, plus a {ClassName}Payload TypedDict documenting its fields.

See ROADMAP.md for the full list of resources and their verification status.

DbResource

midas_nx.db.base.DbResource

Base class for a single /db/* endpoint.

Subclasses set

ENDPOINT: e.g. "/db/NODE" NAME: human-readable name (manual "기능" column), for error messages PRODUCTS: {"gen"}, {"civil"}, or {"gen", "civil"} METHODS: subset of {"POST", "GET", "PUT", "DELETE"} the endpoint actually supports (defaults to all four; override for GET/PUT-only endpoints like MATD).

Also provides .info() — a server-side schema introspection GET (/info/db/...), independent of METHODS/CRUD; see its docstring.

get(client=None) classmethod

Fetch all items. Response is nested under the endpoint's key, e.g. {"NODE": {"1": {...}, "2": {...}}}.

items(client=None) classmethod

Fetch all items, unwrapped to {id: payload} with int ids (e.g. {1: {"X": 0, "Y": 0, "Z": 0}, ...} for Node), instead of .get()'s raw {ENDPOINT_KEY: {"1": {...}, ...}} response. .get() is unchanged; use whichever shape is more convenient.

Returns {} for an empty table. A zero-row response has been observed live in two shapes — {"<KEY>": {}} and a bare {"message": ""} (see docs/live_verification_notes.md) — so this picks the first dict-valued entry rather than the first entry, which would otherwise raise AttributeError on the string value.

info(client=None) classmethod

GET {base url}/info/db/... — server-returned key/type schema for this resource, e.g. GET /info/db/NODE.

Docs: the MIDAS-API manual repo's docs/AUTHENTICATION.md, "/info/db/... — DB 리소스 스키마 인트로스펙션" — undocumented in the per-chapter manual pages this repo's TypedDicts are transcribed from, but documented in the repo's auth guide as a way to ask the server directly for a field's current shape instead of digging through the manual (or as a fallback for the endpoints this SDK hasn't wrapped yet). Not tracked in docs/coverage.json/ROADMAP.md for that reason. Independent of METHODS (schema info, not a data operation) — this is attempted even for GET-less resources (e.g. ch27's DSRC, PUT/DELETE only).

create(items, client=None) classmethod

items: {id: payload_dict}, e.g. {1: {"X": 0, "Y": 0, "Z": 0}}.

update(items, client=None) classmethod

items: {id: payload_dict} — same shape as create().

delete(ids, client=None) classmethod

Delete the listed ids, e.g. [1, 2, 3]. Returns {id: response}.

Issues one DELETE {ENDPOINT}/{id} per id rather than the manual's single ID-keyed "Assign" body. That is not a stylistic choice: the documented body form was measured deleting the entire table regardless of which ids it names (see this module's docstring), which for /db/NODE also takes out every element attached to those nodes. The per-id URL removes exactly the record asked for.

Deleting an id that isn't there is a no-op, so this is safe to call without checking first. If you actually want to empty a table, say so with :meth:delete_all.

delete_all(client=None, *, confirm=False) classmethod

Empty this table — every record, not a selection.

Requires confirm=True. Without it this raises :class:~midas_nx.client.DestructiveOperationError before sending anything, so a mistaken call costs nothing::

Node.delete_all(confirm=True)

This is the manual's documented DELETE call ({"Assign": {...}} against the bare endpoint). Live testing showed it ignoring the ids in that body and clearing the table, so it is exposed under a name that says what it does instead of being reachable by accident through :meth:delete.

For /db/NODE this also removes every element attached to the deleted nodes. There is no undo through the API, and the products raise no confirmation dialog on the API path — the keyword is the only thing standing between a typo and an emptied model, which is why it is required rather than merely recommended.

To remove specific records instead, use :meth:delete.

Product gates

midas_nx.db.base

Generic /db/* CRUD base class.

Source convention: MIDAS-API manual repo, e.g. docs/manual/03_DB_Node_Element.md

1 (/db/NODE). Every /db/* endpoint is ID-keyed under an "Assign" wrapper for

POST/PUT/DELETE; GET returns the full set (no documented per-ID URL filtering across the manual, so we don't invent one).

⚠️ DELETE does not work the way the manual documents it. The manual's worked example is DELETE /db/NODE with {"Assign": {"4": None}}, and chapters disagree on None vs {} per id. Live testing on 2026-07-26 (Civil NX 2026 v2.1) found both forms delete the entire table, ignoring the ids entirely — deleting one node took the whole node table with it, and the elements attached to those nodes with it. The undocumented per-id URL, DELETE {endpoint}/{id}, does the right thing: it removes exactly that record and returns it. Verified across /db/NODE, /db/STLD, /db/LDGR and /db/MATL; deleting an id that doesn't exist is a harmless no-op. :meth:DbResource.delete uses the per-id URL as of v0.14.0. The whole-table form is still reachable, deliberately, as :meth:DbResource.delete_all.

GEN_ONLY = frozenset({'gen'}) module-attribute

CIVIL_ONLY = frozenset({'civil'}) module-attribute

HYPER_S_ONLY = frozenset({'civil'}) module-attribute

NO_DELETE_METHODS = frozenset({'POST', 'GET', 'PUT'}) module-attribute

Nodes and elements

The reference implementation for the resource pattern.

midas_nx.db.node_element.Node

Bases: DbResource

midas_nx.db.node_element.Element

Bases: DbResource