moo.sdk.objects.get_or_create_by_key

moo.sdk.objects.get_or_create_by_key(namespace, key, **kwargs)

Idempotently resolve-or-create an Object keyed by an external id.

The common bootstrap pattern made fast and re-runnable: a second run with the same (namespace, key) returns the existing Object in one indexed query, never a duplicate. On first sight it creates the Object (via the standard create(), so quota/ownership/initialize all apply) and records the mapping.

Parameters:
  • namespace – the key namespace

  • key – the external key value

  • name – the Object name to create (defaults to key)

  • kwargs – forwarded to create() (parents, owner, …)

Returns:

(object, created)