m_rsc_import (zotonic_core v1.0.0-rc.17)
Import model for resources exported by m_rsc_export.
This model handles import-preview and import operations for external resource exports. It keeps import status metadata and supports fetching raw export payloads for authenticated users.
Available Model API Paths
| Method | Path pattern | Description |
|---|---|---|
get | /fetch_raw | Fetch raw exported JSON from a remote URI provided in the payload, for authenticated users. No further lookups. |
Summary
Types
-type import_map() :: #{binary() => m_rsc:resource_id()}.
-type import_result() :: {ok, {m_rsc:resource_id(), import_map()}} | {error, term()}.
-type option() :: {props_forced, map()} | {props_default, map()} | {import_edges, non_neg_integer()} | is_import_deleted | {is_import_deleted, boolean()} | is_authoritative | {is_authoritative, boolean()} | is_no_medium_download | {is_no_medium_download, boolean()} | {allow_category, [binary()]} | {allow_predicate, [binary()]} | {deny_category, [binary()]} | {deny_predicate, [binary()]} | {fetch_options, z_url_fetch:options()} | {uri_template, binary()} | {is_forced_update, boolean()} | {filtermap_rsc, mfa()} | {filtermap_edges, mfa()}.
-type options() :: [option()].
Functions
-spec fetch_preview(Url, Context) -> {ok, m_rsc:props()} | {error, term()} when Url :: string() | binary(), Context :: z:context().
-spec get_import_status(m_rsc:resource(), z:context()) -> {ok, map()} | {error, term()}.
-spec import(map(), z:context()) -> import_result().
-spec import(map(), options(), z:context()) -> import_result().
-spec import(OptLocalId, JSON, options(), z:context()) -> import_result() when OptLocalId :: m_rsc:resource() | undefined, JSON :: map().
import_medium_task(RetryCt, StartDT, MediaUrl, LocalId, RscProps, MediaOptions, PickledContext, Context)
-spec import_medium_task(RetryCt, StartDT, MediaUrl, LocalId, RscProps, MediaOptions, PickledContext, Context) -> Result when RetryCt :: non_neg_integer(), StartDT :: calendar:datetime(), MediaUrl :: binary(), LocalId :: m_rsc:resource_id(), RscProps :: map(), MediaOptions :: m_media:options(), PickledContext :: binary(), Context :: z:context(), Result :: z_pivot_rsc:task_return().
-spec import_uri(Uri, Context) -> import_result() when Uri :: string() | binary(), Context :: z:context().
-spec import_uri(Uri, Options, Context) -> import_result() when Uri :: string() | binary(), Options :: options() | saved, Context :: z:context().
-spec import_uri_recursive(Uri, Options, Context) -> import_result() when Uri :: string() | binary(), Options :: options() | saved, Context :: z:context().
-spec import_uri_recursive_async(Uri, Options, Context) -> import_result() when Uri :: string() | binary(), Options :: options() | saved, Context :: z:context().
-spec install(z:context()) -> ok.
-spec is_imported(m_rsc:resource(), z:context()) -> boolean().
-spec m_get(list(), zotonic_model:opt_msg(), z:context()) -> zotonic_model:return().
-spec mark_imported(RscId, Status, Context) -> ok | {error, enoent} when RscId :: m_rsc:resource_id(), Status :: atom() | binary() | string(), Context :: z:context().
-spec reimport(Id, Context) -> import_result() when Id :: m_rsc:resource_id(), Context :: z:context().
-spec reimport(Id, Options, Context) -> import_result() when Id :: m_rsc:resource_id(), Options :: options() | saved, Context :: z:context().
-spec reimport(Id, RefIds, Options, Context) -> import_result() when Id :: m_rsc:resource_id(), RefIds :: map(), Options :: options() | saved, Context :: z:context().
-spec reimport_recursive(m_rsc:resource_id(), z:context()) -> import_result().
-spec reimport_recursive(m_rsc:resource_id(), map(), options() | saved, z:context()) -> import_result().
-spec reimport_recursive_async(m_rsc:resource_id(), z:context()) -> import_result().
-spec reimport_recursive_async(Id, Options, Context) -> import_result() when Id :: m_rsc:resource_id(), Options :: options() | saved, Context :: z:context().
-spec set_import_status(m_rsc:resource(), map(), z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}.
-spec update_medium_uri(LocalId, Uri, Options, Context) -> {ok, m_rsc:resource_id()} | {error, term()} when LocalId :: m_rsc:resource_id(), Uri :: string() | binary(), Options :: options(), Context :: z:context().