arcgis.apps.expbuilder module

The WebExperience class allows users to work in tandem with the ArcGIS Experience Builder.

WebExperience

class arcgis.apps.expbuilder.expbuilder.WebExperience(item=None, path=None, gis=None, template=None, name=None)

Bases: object

A Web Experience is web-based application that provides viewers with an interactive interface to maps, data, feature layers, and other components of the creator’s design. Though these experiences are normally constructed via a GUI found on ArcGIS Online or Enterprise, this class provides users a host of supplemental options to manage experiences, in addition to basic creation of experiences.

Argument

Description

item

Optional String or Item. The string for an item id or an item of type ‘Web Experience’. If no item is passed, a new experience is created and saved to your active portal.

gis

Optional instance of GIS. If none provided the active gis is used.

template

Optional string. If a new experience is being created, the template used to construct the layout. If necessary and none provided, template will default to blank fullscreen.

path

Optional string. Used if a WebExperience is being based on a local config json file, as one would with Experiences made via the desktop version of Experience Builder.

name

Optional string. If a new experience is being created, the name of the item. Otherwise, will default to “Experience via Python” followed by a random number.

clone(target, owner, **kwargs)

Deprecated since version 2.3.0: Removed in: 3.0.0. Pass in the Web Experience item to gis.content.clone_items() instead.

Clones the experience and all of it’s data sources to a target GIS. User must have admin privileges on the original item’s GIS, and provide an authenticated instance of a target GIS. Users must also specify the name of an account on the target GIS to own the items. Also accepts arguments for clone_items()

Argument

Description

target

Required GIS. An authenticated instance of the GIS that the user wishes to clone the experience to.

owner

Required string. The username of the account that will be the owner of the experience and its data source items in the target GIS.

**kwargs

Optional additional arguments. See Item.clone_items() for the full list.

Returns

The item corresponding to the cloned experience in the target GIS.

property datasources

Shows the data sources dictionary found in the experience’s draft, allowing users to quickly get info on all of the other items in their experience. Changing this dictionary will change the draft, making it convenient for remapping data sources.

delete()

Deletes the experience and its associated item from the portal.

Returns

A boolean indicating the success of the operation.

property item

Returns the portal item associated with the WebExperience, if possible. Experiences made from local json files won’t have an item property until they are added to a portal using upload().

property itemid

Returns the item ID of the associated portal item, if possible. As with item, Experiences made from local json files won’t have an itemid property until they are added to a portal using upload().

preview(width=800, height=500)

Show a preview of the current experience draft. The default is a width of 800 and height of 500. Note that this should be used to visualize unsaved changes to the WebExperience object; to see the actively published version of the object, view() should be used.

Argument

Description

width

Optional integer. The desired width to show the preview.

height

Optional integer. The desired height to show the preview.

Note

In some cases, a dialogue box may pop up asking for credentials when calling this method. If the preview isn’t rendering, check if pop-ups are disabled in your browser.

Returns

An IFrame display of the Experience if possible, else the item url is returned to be clicked on.

reload()

Resets any changes that the user has made to the last saved state. Note that this only applies to changes made through a Python API object, and not the GUI.

Returns

A boolean indicating the success of the operation.

save(title=None, tags=None, access=None, publish=False, duplicate=False, include_private=None, item_properties={})

This method will save your Web Experience to your active GIS. The experience will be saved with unpublished changes unless the publish parameter is set to True. Note that this is different from the publish() method in that this will save and publish the unsaved draft of the WebExperience object, as opposed to the already existing save state.

The title only needs to be specified if a change is wanted, otherwise the existing title is used.

Argument

Description

title

Optional string. The new title of the WebExperience, if desired.

tags

Optional string. Updated tags for the WebExperience, if desired.

access

Optional string. The sharing setting of the WebExperience. If none is specified, the current access is kept. This is used when the publish parameter is set to True.

Values: private | org | public

publish

Optional boolean. If True, the experience is saved and also published. Default is False, meaning the experience is saved with unpublished changes.

duplicate

Optional boolean. If True, the experience is duplicated and a new WebExperience object is saved with any specified changes to title, tags, access, or publish included. Essentially functions as a “Save As” method. Default is False, meaning changes are saved to the original object.

include_private

Optional boolean. Only to be included when duplicate is True. If True, the private resources of the original item will be included in the new item.

item_properties

Optional dictionary. Contains a variety of properties that can be set when creating a new item, much like item.update(). See below for a table containing possible properties.

Key:Value Dictionary Options for Argument item_properties

Key

Value

description

Optional string. Description of the item.

url

Optional string. URL to item that are based on URLs.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

accessInformation

Optional string. Information on the source of the content.

licenseInfo

Optional string. Any license information or restrictions regarding the content.

culture

Optional string. Locale, country and language information.

Returns

A boolean indicating the success of the operation.

upload(gis=None, publish=False, title=None, item_mapping=None, auto_remap=False, item_properties={})

Adds a WebExperience created locally through the Developer Edition to a specified portal. After doing this, the WebExperience object will obtain item and itemid properties. Gives users options to remap their experience’s datasources to items present in the portal, both manually or automatically

Argument

Description

gis

Optional GIS object. The portal to add the WebExperience to. If none is passed in, will default to the GIS of the WebExperience object.

publish

Optional boolean. Publishes the experience when adding it to the portal. Default is False.

title

Optional string. Allows a user to specify the title of their new experience in the portal.

item_mapping

Optional dictionary. Allows users to manually remap the datasources of their experience to datasources present in the portal. See example dictionary below.

auto_remap

Optional boolean. Searches the portal for matching datasources and automatically remaps the experience to use those accordingly. Default is False.

item_properties

Optional dictionary. Contains a variety of properties that can be set when creating a new item, much like ContentManager.add(). See below for a table containing possible properties.

Key:Value Dictionary Options for Argument item_properties

Key

Value

description

Optional string. Description of the item.

url

Optional string. URL to item that are based on URLs.

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

accessInformation

Optional string. Information on the source of the content.

licenseInfo

Optional string. Any license information or restrictions regarding the content.

culture

Optional string. Locale, country and language information.

commentsEnabled

Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).

access

Optional string. Valid values are private, org, or public. Defaults to private.

overwrite

Optional boolean. Default is false. Controls whether item can be overwritten.

Returns

The newly added portal item, if successful. Otherwise, returns False.

view(width=800, height=500)

Shows the currently published experience, if possible. Default width is 800 and default height is 500. Note that this displays the actively published version of the WebExperience object; to visualize unsaved changes, preview() should be used.

Argument

Description

width

Optional integer. The desired width to show the preview.

height

Optional integer. The desired height to show the preview.

Note

In some cases, a dialogue box may pop up asking for credentials when calling this method. If the preview isn’t rendering, check if pop-ups are disabled in your browser.

Returns

An IFrame display of the Experience if possible, else the item url is returned to be clicked on. If the item is unpublished, the function returns False.