The Hub
is the main entry point into the Hub module.
It can be used as shown in the following code example.
from arcgis.gis import GIS
gis = GIS("https://arcgis.com", "<username>", "<password>")
myHub = gis.hub
a_Initiative = myHub.initiatives.get(itemId)
a_Site = myHub.sites.get(a_Initiative.site_id)
b_Site = myHub.sites.get(itemId)
c_Page = myHub.pages.get(itemId)
myEvents = myHub.events.search()
Hub
-
class
arcgis.apps.hub.hub.
Hub
(gis) Entry point into the Hub module. Lets you access an individual hub and its components.
Parameter
Description
url
Required string. If no URL is provided by user while connecting to the GIS, then the URL will be ArcGIS Online.
GIS
Required authenticated GIS object for the ArcGIS Online organization associated with your Hub.
-
property
community_org_id
Returns the AGOL org id of the Community Organization associated with this Premium Hub.
-
property
community_org_url
Returns the AGOL org id of the Community Organization associated with this Premium Hub.
-
property
enterprise_org_id
Returns the AGOL org id of the Enterprise Organization associated with this Premium Hub.
-
property
Initiative
-
class
arcgis.apps.hub.initiatives.
Initiative
(gis, initiativeItem) Represents an initiative within a Hub. An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration.
-
add_content
(items_list) Adds a batch of items to the initiative content library.
Parameter
Description
items_list
Required list. A list of Item or item ids to add to the initiative.
-
delete
() Deletes the initiative, its site and associated groups. If unable to delete, raises a RuntimeException.
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Delete an initiative successfully initiative1 = myHub.initiatives.get('itemId12345') initiative1.delete() >> True
-
reassign_to
(target_owner) Allows the administrator to reassign the initiative object from one user to another.
Note
This will transfer ownership of all items (site, pages, content) and groups that belong to this initiative to the new target_owner.
Parameter
Description
target_owner
Required string. The new desired owner of the initiative.
Shares an initiative and associated site with the specified list of groups.
Parameter
Description
everyone
Optional boolean. Default is False, don’t share with everyone.
org
Optional boolean. Default is False, don’t share with the organization.
private
Optional boolean. Default is False, don’t restrict access to owner.
groups
Optional list of group ids as strings, or a list of arcgis.gis.Group objects.
- Returns
A dictionary with key “notSharedWith” containing array of groups with which the items could not be shared.
Returns the tags of the initiative item
Stops sharing of the initiative and its associated site with the specified list of groups.
Parameter
Description
groups
Required list of group names as strings, or a list of arcgis.gis.Group objects, or a comma-separated list of group IDs.
- Returns
Dictionary with key “notUnsharedFrom” containing array of groups from which the items could not be unshared.
-
update
(initiative_properties=None) Updates the initiative.
Note
For initiative_properties, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the initiative’s description, then only provide the description argument in initiative_properties.
Parameter
Description
initiative_properties
Required dictionary. See URL below for the keys and values.
To find the list of applicable options for argument initiative_properties, please see the Item
update()
documentation.- Returns
A boolean indicating success (True) or failure (False).
USAGE EXAMPLE: Update an initiative successfully initiative1 = myHub.initiatives.get('itemId12345') initiative1.update(initiative_properties={'description':'Create your own initiative to organize people around a shared goal.'}) >> True
-
Site
-
class
arcgis.apps.hub.sites.
Site
(gis, site_item) Represents a site within a Hub. A site is a container for web accessible content.
-
add_content
(items_list) Adds a batch of items to the site content library.
Parameter
Description
items_list
Required list. A list of Item or item ids to add to the Site.
-
delete
() Deletes the Enterprise site. If unable to delete, raises a RuntimeException.
- Returns
A bool containing True (for success) or False (for failure).
Note
Deleting the site object (instead of the Item object) for the site is encouraged, to also delete the groups associated with the site.
USAGE EXAMPLE: Delete a site successfully site1 = gis.sites.get('itemId12345') site1.delete() >> True
-
reassign_to
(target_owner) Allows the administrator to reassign the Enterprise site object from one user to another.
Note
This will transfer ownership of all items (site, pages, content) and groups to the new target_owner.
Parameter
Description
target_owner
Required string. The new desired owner of the site.
-
search
(query=None, item_type=None) Search and filter content for a site.
Parameter
Description
query
Optional string. Filters items by presence of search query in title.
item_type
Optional list. Returns items of particular type.
- Returns
List of items shared with this site.
USAGE EXAMPLE: Succcessfully fetch items of item_type 'Web Mapping Application' for particular query 'school' for site site1 = myHub.sites.get('itemId12345') site_apps = site1.search(query='school', item_type='Web Map') site_apps >> List of relevant items
Returns the tags of the site item
-
update
(site_properties=None, subdomain=None) Updates the site.
Note
For site_properties, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the site’s description, then only provide the description argument in site_properties.
Parameter
Description
site_properties
Required dictionary. See URL below for the keys and values.
subdomain
Optional string. New subdomain for the site.
To find the list of applicable options for argument site_properties - https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update
- Returns
A boolean indicating success (True) or failure (False).
-
update_layout
(layout) Updates the layout of the site.
Note
This operation can only be performed by the owner of the site or by an org administrator.
Parameter
Description
layout
Required dictionary. The new layout dictionary to update to the site.
- Returns
A boolean indicating success (True) or failure (False).
USAGE EXAMPLE: Update a site successfully site1 = myHub.sites.get('itemId12345') site_layout = site1.layout site_layout.sections[0].rows[0].cards.pop(0) site1.update_layout(layout = site_layout) >> True
-
update_theme
(theme) Updates the theme of the site.
Note
This operation can only be performed by the owner of the site or by an org administrator.
Parameter
Description
theme
Required dictionary. The new theme dictionary to update to the site.
- Returns
A boolean indicating success (True) or failure (False).
USAGE EXAMPLE: Update a site successfully site1 = myHub.sites.get('itemId12345') site_theme = site1.theme site_theme.body.background = '#ffffff' site1.update_theme(theme = site_theme) >> True
-
Page
-
class
arcgis.apps.hub.sites.
Page
(gis, page_item) Represents a page belonging to a site in Hub. A Page is a layout of content that can be rendered within the context of a Site
-
delete
() Deletes the page. If unable to delete, raises a RuntimeException.
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Delete a page successfully page1 = myHub.pages.get('itemId12345') page1.delete() >> True
Returns the tags of the page item
-
update
(page_properties=None, slug=None) Updates the page.
Note
For page_properties, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the page’s description, then only provide the description argument in page_properties.
Parameter
Description
page_properties
Required dictionary. See URL below for the keys and values.
slug
Optional string. The slug or subdomain for the page.
To find the list of applicable options for argument page_properties - https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update
- Returns
A boolean indicating success (True) or failure (False).
USAGE EXAMPLE: Update a page successfully page1 = mySite.pages.get('itemId12345') page1.update(page_properties={'description':'Description for page.'}) >> True
-
Event
-
class
arcgis.apps.hub.
Event
(gis, event_object) Represents an event in a Hub. A Hub has many Events that can be associated with an Initiative. Events are meetings for people to support an Initiative. Events are scheduled by an organizer and have many attendees. An Event has a Group so that they can include content for preparation as well as gather and archive content during the event for later retrieval or analysis.
-
delete
() Deletes an event
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Delete an event successfully event1 = myhub.events.get(24) event1.delete() >> True
-
update
(event_properties) Updates properties of an event
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Update an event successfully event1 = myhub.events.get(id) event_properties = {'status': 'planned', description: 'Test'} event1.update(event_properties) >> True
-
InitiativeManager
-
class
arcgis.apps.hub.initiatives.
InitiativeManager
(hub, initiative=None) Helper class for managing initiatives within a Hub. This class is not created by users directly. An instance of this class, called ‘initiatives’, is available as a property of the Hub object. Users call methods on this ‘initiatives’ object to manipulate (add, get, search, etc) initiatives.
-
add
(title, description=None, site=None) Adds a new initiative to the Hub.
Parameter
Description
title
Required string.
description
Optional string.
site
Optional Site object.
- Returns
The
Initiative
object if successfully added, None if unsuccessful.
USAGE EXAMPLE: Add an initiative successfully initiative1 = myHub.initiatives.add(title='Vision Zero Analysis') initiative1.item
-
clone
(initiative, origin_hub=None, title=None) Clone allows for the creation of an initiative that is derived from the current initiative.
Note
If both your origin_hub and destination_hub are Hub Basic organizations, please use the clone method supported under the
SiteManager
class.Parameter
Description
initiative
Required
Initiative
object of initiative to be cloned.origin_hub
Optional
Hub
object. Required only for cross-org clones where the initiative being cloned is not an item with public access.title
Optional String.
- Returns
Initiative
object
USAGE EXAMPLE: Clone an initiative in another organization #Connect to Hub hub_origin = gis1.hub hub_destination = gis2.hub #Fetch initiative initiative1 = hub_origin.initiatives.get('itemid12345') #Clone in another Hub initiative_cloned = hub_destination.initiatives.clone(initiative1, origin_hub=hub_origin) initiative_cloned.item USAGE EXAMPLE: Clone initiative in the same organization myhub = gis.hub initiative1 = myhub.initiatives.get('itemid12345') initiative2 = myhub.initiatives.clone(initiative1, title='New Initiative')
-
get
(initiative_id) Returns the initiative object for the specified initiative_id.
Parameter
Description
initiative_id
Required string. The initiative itemid.
- Returns
The
Initiative
object if the item is found, None if the item is not found.
USAGE EXAMPLE: Fetch an initiative successfully initiative1 = myHub.initiatives.get('itemId12345') initiative1.item
-
search
(title=None, owner=None, created=None, modified=None, tags=None) Searches for initiatives.
Parameter
Description
title
Optional string. Return initiatives with provided string in title.
owner
Optional string. Return initiatives owned by a username.
created
Optional string. Date the initiative was created. Shown in milliseconds since UNIX epoch.
modified
Optional string. Date the initiative was last modified. Shown in milliseconds since UNIX epoch
tags
Optional string. User-defined tags that describe the initiative.
- Returns
A list of matching
Initiative
objects.
-
SiteManager
-
class
arcgis.apps.hub.sites.
SiteManager
(gis, initiative=None) Helper class for managing sites within a Hub. This class is not created by users directly. An instance of this class, called ‘sites’, is available as a property of the Hub object. Users call methods on this ‘sites’ object to manipulate (add, get, search, etc) sites.
-
add
(title, subdomain=None) Adds a new site.
Note
Unicode characters are not allowed in the title of the site.
Parameter
Description
title
Required string.
subdomain
Optional string. Available ONLY with Enterprise Sites.
- Returns
The site if successfully added, None if unsuccessful.
USAGE EXAMPLE: Add an open data site in Hub successfully site1 = myHub.sites.add(title='My first site') site1.item
USAGE EXAMPLE: Add an initiative site successfully initiative_site = initiative1.sites.add(title=title) site1.item
-
clone
(site, pages=True, title=None) Clone allows for the creation of a site that is derived from the current site.
Note
Use this method if you are cloning a Site object from a Hub Basic or Enterprise environment. To clone from Hub Premium environments, please use the initiatives.clone method.
Parameter
Description
site
Required Site object of site to be cloned.
pages
Optional Boolean. Decides if pages will be copied. Default is True.
title
Optional String.
- Returns
Site.
-
get
(site_id) Returns the site object for the specified site_id.
Parameter
Description
site_id
Required string. The site itemid.
- Returns
The site object if the item is found, None if the item is not found.
USAGE EXAMPLE: Fetch a site successfully site1 = myHub.sites.get('itemId12345') site1.item
-
get_by_domain
(domain_url) Returns the site object for the specified domain url.
Parameter
Description
domain_url
Required string. The site url.
- Returns
The site object if the item is found, None if the item is not found.
Note
You may only fetch sites by domain local to your environment. E.g. If your Hub instance is an ArcGIS Online instance, then you can fetch ArcGIS Online sites by url, and if you have signed into an ArcGIS Enterprise Instance, only sites on premise will be available.
USAGE EXAMPLE: Fetch a site successfully site1 = myHub.sites.get_by_domain('opendata.dc.gov') site1.item
-
search
(title=None, owner=None, created=None, modified=None, tags=None) Searches for sites.
Parameter
Description
title
Optional string. Return sites with provided string in title.
owner
Optional string. Return sites owned by a username.
created
Optional string. Date the site was created. Shown in milliseconds since UNIX epoch.
modified
Optional string. Date the site was last modified. Shown in milliseconds since UNIX epoch
tags
Optional string. User-defined tags that describe the site.
- Returns
A list of matching sites.
-
PageManager
-
class
arcgis.apps.hub.sites.
PageManager
(gis, site=None) Helper class for managing pages within a Hub. This class is not created by users directly. An instance of this class, called ‘pages’, is available as a property of the Site object. Users call methods on this ‘pages’ object to manipulate (add, get, search, etc) pages for a site.
-
add
(title, site=None) Returns the pages linked to the specific site.
Parameter
Description
title
Required string. The title of the new page.
site
Optional Site. The site object to add the page to.
- Returns
The page if successfully added, None if unsuccessful.
USAGE EXAMPLE: Add a page to a site successfully page1 = mySite.pages.add(title='My first page') page1.item
USAGE EXAMPLE: Add a page successfully page2 = myHub.pages.add(title='My second page', site=mySite) page2.item
-
clone
(page, site=None) Clone allows for the creation of a page that is derived from the current page.
Parameter
Description
page
Required Page object of page to be cloned.
site
Optional Site object.
- Returns
Page.
USAGE EXAMPLE: Clone a page to a site successfully #Fetch page page1 = myhub.pages.get('itemId12345') page1.item #Clone it page2 = mySite.pages.clone(page1) page2.item
-
get
(page_id) Returns the page object for the specified page_id.
Parameter
Description
page_id
Required string. The page itemid.
- Returns
The page object if the item is found, None if the item is not found.
USAGE EXAMPLE: Fetch a page successfully page1 = myHub.pages.get('itemId12345') page1.item
-
link
(page, site=None, slug=None) Links the page to the specific site.
Parameter
Description
page
Required string. The page object to link.
site
Optional Site. The site object to link page to.
slug
Optional string. The slug reference of the page in this site.
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Link a page successfully for specific site mySite.pages.link(page_id='itemId12345') >> True
USAGE EXAMPLE: Link a page successfully for site object passed as param myHub.pages.link(page_id='itemId12345', site=mySite) >> True
-
search
(title=None, owner=None, created=None, modified=None, tags=None) Searches for pages.
Parameter
Description
title
Optional string. Return pages with provided string in title.
owner
Optional string. Return pages owned by a username.
created
Optional string. Date the page was created. Shown in milliseconds since UNIX epoch.
modified
Optional string. Date the page was last modified. Shown in milliseconds since UNIX epoch
tags
Optional string. User-defined tags that describe the page.
- Returns
A list of matching pages.
-
unlink
(page, site=None) Unlinks the page from the specific site.
Note
This method will only detach the page from the site. In order to remove links to this page from the site’s UI, you will have to manually remove it from the site through the site’s Layout Editior.
Parameter
Description
page
Required Page. The page object to unlink.
site
Optional Site. The site object to unlink page from.
- Returns
A bool containing True (for success) or False (for failure).
USAGE EXAMPLE: Unlink a page successfully from specific site mySite.pages.unlink(page_id='itemId12345') >> True
USAGE EXAMPLE: Unlink a page successfully from site object passed as param myHub.pages.unlink(page_id='itemId12345', site=mySite) >> True
-
EventManager
-
class
arcgis.apps.hub.events.
EventManager
(hub, event=None) Helper class for managing events within a Hub. This class is not created by users directly. An instance of this class, called ‘events’, is available as a property of the Hub object. Users call methods on this ‘events’ object to manipulate (add, search, get_map etc) events of a particular Hub.
-
add
(event_properties) Adds an event for an initiative.
Parameter
Description
event_properties
Required dictionary. See table below for the keys and values.
Key:Value Dictionary Options for Argument event_properties
Key
Value
title
Required string. Name of event.
description
Required string. Description of the event.
initiaitve_id
Required string. Name label of the item.
venue
Required string. Venue name for the event.
address1
Required string. Street address for the venue.
status
Required string. Access of event. Valid values are private, planned, public, draft.
startDate
Required start date of the event in milliseconds since UNIX epoch.
endDate
Required end date of the event in milliseconds since UNIX epoch.
isAllDay
Required boolean. Indicates if the event is a day long event.
capacity
Optional integer. The attendance capacity of the event venue.
address2
Optional string. Additional information about event venue street address.
onlineLocation
Optional string. Web URL or other details for online event.
organizers
Optional list of dictionary of keys name and contact for each organizer’s name and email. Default values are name, email, username of event creator.
sponsors
Optional list of dictionary of keys name and contact for each sponsor’s name and contact.
- Returns
Event if successfully added.
USAGE EXAMPLE: Add an event successfully event_properties = { 'title':'Test Event', 'description': 'Testing with python', 'initiativeId': '43f..', 'venue': 'Washington Monument', 'address1': '2 15th St NW, Washington, District of Columbia, 20024', 'status': 'planned', 'startDate': 1562803200, 'endDate': 1562889600, 'isAllDay': 1 } new_event = myhub.events.add(event_properties)
-
get
(event_id) Get the event for the specified event_id.
Parameter
Description
event_id
Required integer. The event identifier.
- Returns
The
Event
object.
-
search
(initiative_id=None, title=None, venue=None, organizer_name=None) Searches for events within a Hub.
Parameter
Description
initiative_id
Optional string. Initiative itemid.
title
Optional string. Title of the event.
venue
Optional string. Venue where event is held.
organizer_name
Optional string. Name of the organizer of the event.
- Returns
A list of matching indicators.
-