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

MethodPath patternDescription
get/fetch_rawFetch raw exported JSON from a remote URI provided in the payload, for authenticated users. No further lookups.

Summary

Types

import_map()

-type import_map() :: #{binary() => m_rsc:resource_id()}.

import_result()

-type import_result() :: {ok, {m_rsc:resource_id(), import_map()}} | {error, term()}.

option()

-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()}.

options()

-type options() :: [option()].

Functions

fetch_preview(Url, Context)

-spec fetch_preview(Url, Context) -> {ok, m_rsc:props()} | {error, term()}
                       when Url :: string() | binary(), Context :: z:context().

fetch_preview(Url, Options, Context)

-spec fetch_preview(Url, Options, Context) -> {ok, m_rsc:props()} | {error, term()}
                       when Url :: string() | binary(), Options :: options(), Context :: z:context().

get_import_status(Rsc, Context)

-spec get_import_status(m_rsc:resource(), z:context()) -> {ok, map()} | {error, term()}.

import(JSON, Context)

-spec import(map(), z:context()) -> import_result().

import(JSON, Options, Context)

-spec import(map(), options(), z:context()) -> import_result().

import(OptLocalId, JSON, Options, Context)

-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().

import_referred_ids_task(RefIds, ImportedIds, Options, Context)

-spec import_referred_ids_task(RefIds, ImportedIds, Options, Context) -> ok
                                  when
                                      RefIds :: map(),
                                      ImportedIds :: map(),
                                      Options :: options() | saved,
                                      Context :: z:context().

import_uri(Uri, Context)

-spec import_uri(Uri, Context) -> import_result()
                    when Uri :: string() | binary(), Context :: z:context().

import_uri(Uri, Options, Context)

-spec import_uri(Uri, Options, Context) -> import_result()
                    when
                        Uri :: string() | binary(), Options :: options() | saved, Context :: z:context().

import_uri_recursive(Uri, Options, Context)

-spec import_uri_recursive(Uri, Options, Context) -> import_result()
                              when
                                  Uri :: string() | binary(),
                                  Options :: options() | saved,
                                  Context :: z:context().

import_uri_recursive_async(Uri, Options, Context)

-spec import_uri_recursive_async(Uri, Options, Context) -> import_result()
                                    when
                                        Uri :: string() | binary(),
                                        Options :: options() | saved,
                                        Context :: z:context().

install(Context)

-spec install(z:context()) -> ok.

is_imported(Rsc, Context)

-spec is_imported(m_rsc:resource(), z:context()) -> boolean().

m_get/3

mark_imported(RscId, Status, Context)

-spec mark_imported(RscId, Status, Context) -> ok | {error, enoent}
                       when
                           RscId :: m_rsc:resource_id(),
                           Status :: atom() | binary() | string(),
                           Context :: z:context().

reimport(Id, Context)

-spec reimport(Id, Context) -> import_result() when Id :: m_rsc:resource_id(), Context :: z:context().

reimport(Id, Options, Context)

-spec reimport(Id, Options, Context) -> import_result()
                  when Id :: m_rsc:resource_id(), Options :: options() | saved, Context :: z:context().

reimport(Id, RefIds, Options, Context)

-spec reimport(Id, RefIds, Options, Context) -> import_result()
                  when
                      Id :: m_rsc:resource_id(),
                      RefIds :: map(),
                      Options :: options() | saved,
                      Context :: z:context().

reimport_recursive(Id, Context)

-spec reimport_recursive(m_rsc:resource_id(), z:context()) -> import_result().

reimport_recursive(Id, RefIds, Options, Context)

-spec reimport_recursive(m_rsc:resource_id(), map(), options() | saved, z:context()) -> import_result().

reimport_recursive_async(Id, Context)

-spec reimport_recursive_async(m_rsc:resource_id(), z:context()) -> import_result().

reimport_recursive_async(Id, Options, Context)

-spec reimport_recursive_async(Id, Options, Context) -> import_result()
                                  when
                                      Id :: m_rsc:resource_id(),
                                      Options :: options() | saved,
                                      Context :: z:context().

set_import_status(Rsc, Status, Context)

-spec set_import_status(m_rsc:resource(), map(), z:context()) ->
                           {ok, m_rsc:resource_id()} | {error, term()}.

update_medium_uri(LocalId, Uri, Options, Context)

-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().