Skip to content

Add Mosaic API coverage: data models, workspaces, smart attributes, settings - #255

Closed
aidan-codes-stuff wants to merge 2 commits into
MicroStrategy:masterfrom
aidan-codes-stuff:mosaic-coverage
Closed

Add Mosaic API coverage: data models, workspaces, smart attributes, settings#255
aidan-codes-stuff wants to merge 2 commits into
MicroStrategy:masterfrom
aidan-codes-stuff:mosaic-coverage

Conversation

@aidan-codes-stuff

Copy link
Copy Markdown

Summary

Adds full SDK coverage for the Mosaic (semantic layer) REST API surface — 90 operations currently unavailable in mstrio-py:

Module Coverage
mstrio/api/data_models.py 64 wrappers for /api/model/dataModels/* + /api/dataModels/*: model lifecycle, tables, attributes, metrics, fact metrics, folders, links, external data models (data mesh), security filters, object ACLs/translations, YAML export/restore, publish + status polling
mstrio/api/workspaces.py 13 wrappers for /api/dataServer/workspaces/*: workspaces, pipelines, pipeline tables
mstrio/api/smart_attributes.py 6 wrappers for smart attributes (standalone + data-model-scoped)
mstrio/api/mosaic.py 4 wrappers for Mosaic SSO admin settings (keytab upload, stage/commit settings)

High-level classes follow the established Entity/mixin conventions and are version-gated at 11.6.0100:

  • DataModel + DataModelTable / DataModelAttribute / DataModelMetric / DataModelFactMetric / DataModelSecurityFilter in mstrio.modeling.data_model, with list_data_models and per-component list_* functions
  • Workspace / Pipeline / PipelineTable in mstrio.project_objects
  • SmartAttribute in mstrio.modeling.schema.attribute
  • MosaicSsoSettings + module functions in mstrio.server
  • A code_snippets/ example per module; README and NEWS updated

Design notes

  • Changesets: modeling writes default to self-managed changesets (open → commit → delete per call, matching mstrio.api.attributes), and additionally accept a caller-owned changeset_id. This is necessary because the server enforces a minimum committable model: at least one table per model (8004e46f), at least one attribute or metric per table (8004e42f), and displays on every attribute (8004cf06). DataModel.create(tables=..., attributes=...) builds that minimum shape in a single changeset and resolves by-name logical-table references in attribute bodies, so callers are not exposed to the create-order id chicken-and-egg.
  • DataModel.publish() wraps the full three-step runtime flow (create instance → publish with per-table refresh policies → poll publishStatus), since the publish POST returns 204 fire-and-forget.
  • Runtime endpoints (/api/dataModels/*, /api/dataServer/*) always send X-MSTR-ProjectID (defaulted from the connection) — several reject its absence with ERR006 even when a project is selected on the session.
  • export_data_model returns application/yaml and is handled without the JSON ErrorHandler; restore_data_model and upload_mosaic_keytab use the multipart idiom from mstrio.api.migration.

Testing

  • Endpoint conformance against the public OpenAPI specification in both directions per module (every documented operation has exactly one wrapper; no undocumented endpoints).
  • black / isort / flake8 clean with the repo configuration; import mstrio and compileall clean on Python 3.12.
  • Live-validated against a Strategy One 11.6.0500 cloud environment: all read paths on existing Mosaic models, and the full create → alter → save-as → YAML export → instance/publish-status → delete lifecycle on scratch objects (changeset rollback verified to leave no orphan metadata on failed commits).

A companion GitHub Issue will reference this PR per the contribution guidelines.

🤖 Generated with Claude Code

…ettings

Adds full SDK coverage for the Mosaic (semantic layer) REST API surface —
90 operations previously unavailable in mstrio-py:

- mstrio/api/data_models.py: 64 wrappers for /api/model/dataModels/* and
  /api/dataModels/* (model lifecycle, tables, attributes, metrics, fact
  metrics, folders, links, external data models, security filters, object
  ACLs/translations, YAML export/restore, publish + status polling)
- mstrio/api/workspaces.py: 13 wrappers for /api/dataServer/workspaces/*
  (workspaces, pipelines, pipeline tables)
- mstrio/api/smart_attributes.py: 6 wrappers for smart attributes
- mstrio/api/mosaic.py: 4 wrappers for Mosaic SSO admin settings
- High-level classes: DataModel + DataModelTable/Attribute/Metric/
  FactMetric/SecurityFilter (mstrio.modeling.data_model), Workspace/
  Pipeline/PipelineTable (mstrio.project_objects), SmartAttribute,
  MosaicSsoSettings; all version-gated at 11.6.0100
- code_snippets for each module; README and NEWS entries

Modeling writes support both self-managed changesets (default) and a
caller-owned changeset_id, because servers enforce a minimum committable
model: at least one table per model (8004e46f), at least one attribute or
metric per table (8004e42f), and displays on every attribute (8004cf06).
DataModel.create(tables=..., attributes=...) builds that minimum shape in
a single changeset, resolving by-name logical-table references. Runtime
endpoints always send X-MSTR-ProjectID (required by ERR006 even with a
project selected on the session).

Validated against the public OpenAPI specification (endpoint conformance
in both directions per module) and live against a Strategy One 11.6.0500
cloud environment (full create/alter/publish/delete lifecycle on scratch
objects).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MstrException takes an err_data dict, not a message string — the previous
code raised AttributeError ('str' object has no attribute 'get') instead
of the real publish error. Timeouts now raise MstrTimeoutError. Also
documents two field-verified publish behaviors: connect_live models reject
the publish trigger (ERR006), and the per-instance publishStatus can stay
at 1 after the cube has finished loading (cross-check cubes.status).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@apiotrowskiMicroStrategy

Copy link
Copy Markdown
Collaborator

Dedicated module for Mosaic Model will come in 26.07 release cycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants