arcgis.apps.hub module
TheHub
is the main entry point into the Hub module.It can be used as shown in the following code example.
fromarcgis.gisimportGISgis=GIS("https://arcgis.com","<username>","<password>")myHub=gis.huba_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
- classarcgis.apps.hub.hub.Hub(gis: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 connectingto the GIS, then the URL will be ArcGIS Online.
GIS
Required authenticated GIS object for the ArcGIS Onlineorganization associated with your Hub.
- propertycommunity_org_id:str
Returns the AGOL org id of the Community Organization associated with this Premium Hub.
- propertycommunity_org_url:str
Returns the AGOL org id of the Community Organization associated with this Premium Hub.
- propertyenterprise_org_id:str
Returns the AGOL org id of the Enterprise Organization associated with this Premium Hub.
Initiative
- classarcgis.apps.hub.initiatives.Initiative(gis,initiativeItem)
Represents an initiative within a Hub. An Initiative supportspolicy- or activity-oriented goals through workflows, tools and team collaboration.
- add_content(items_list: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()→bool
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).
USAGEEXAMPLE:Deleteaninitiativesuccessfullyinitiative1=myHub.initiatives.get('itemId12345')initiative1.delete()>>True
- reassign_to(target_owner:str)
Allows the administrator to reassign the initiative object from oneuser to another.
Note
This will transfer ownership of all items (site, pages, content) and groups thatbelong to this initiative to the new target_owner.
Parameter
Description
target_owner
Required string. The new desired owner of the initiative.
- share(everyone=False,org=False,groups=None,allow_members_to_edit=False)
Shares an initiative and associated site with the specified list of groups.
Parameter
Description
everyone
Optional boolean. Default is False, don’t share witheveryone.
org
Optional boolean. Default is False, don’t share withthe organization.
private
Optional boolean. Default is False, don’t restrictaccess to owner.
groups
Optional list of group ids as strings, or a list ofarcgis.gis.Group objects.
- Returns:
A dictionary with key “notSharedWith” containing array of groups with which the items could not be shared.
- unshare(groups:list)→dict
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 theinitiative’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 argumentinitiative_properties, please see theItem
update()
documentation.- Returns:
A boolean indicating success (True) or failure (False).
USAGEEXAMPLE:Updateaninitiativesuccessfullyinitiative1=myHub.initiatives.get('itemId12345')initiative1.update(initiative_properties={'description':'Create your own initiative to organize people around a shared goal.'})>>True
Site
- classarcgis.apps.hub.sites.Site(gis,site_item:Item)
Represents a site within a Hub. A site is a container forweb accessible content.
- add_content(items_list: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()→bool
Deletes the Enterprise site. If unable to delete, raises a RuntimeException.
- Returns:
A bool containing True (for success) or False (for failure).
Note
Deleting thesite object (instead of theItem object) for the site is encouraged,to also delete the groups associated with the site.
USAGEEXAMPLE:Deleteasitesuccessfullysite1=gis.sites.get('itemId12345')site1.delete()>>True
- propertypages:PageManager
The resource manager for an Initiative’s indicators.See
PageManager
.
- reassign_to(target_owner:str)
Allows the administrator to reassign the Enterprise site object from oneuser 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:str|None=None,item_type:list|None=None)→list
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.
USAGEEXAMPLE:Succcessfullyfetchitemsofitem_type'Web Mapping Application'forparticularquery'school'forsitesite1=myHub.sites.get('itemId12345')site_apps=site1.search(query='school',item_type='Web Map')site_apps>>Listofrelevantitems
- 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 thesite’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:dict)→bool
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).
USAGEEXAMPLE:Updateasitesuccessfullysite1=myHub.sites.get('itemId12345')site_layout=site1.layoutsite_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).
USAGEEXAMPLE:Updateasitesuccessfullysite1=myHub.sites.get('itemId12345')site_theme=site1.themesite_theme.body.background='#ffffff'site1.update_theme(theme=site_theme)>>True
Page
- classarcgis.apps.hub.sites.Page(gis,page_item:Item)
Represents a page belonging to a site in Hub. A Page is a layout ofcontent that can be rendered within the context of a Site
- delete()→bool
Deletes the page. If unable to delete, raises a RuntimeException.
- Returns:
A bool containing True (for success) or False (for failure).
USAGEEXAMPLE:Deleteapagesuccessfullypage1=myHub.pages.get('itemId12345')page1.delete()>>True
- 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 thepage’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).
USAGEEXAMPLE:Updateapagesuccessfullypage1=mySite.pages.get('itemId12345')page1.update(page_properties={'description':'Description for page.'})>>True
Event
- classarcgis.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 organizerand have many attendees. An Event has a Group so that they can include content for preparationas well as gather and archive content during the event for later retrieval or analysis.
- delete()→bool
Deletes an event
- Returns:
A bool containing True (for success) or False (for failure).
USAGEEXAMPLE:Deleteaneventsuccessfullyevent1=myhub.events.get(24)event1.delete()>>True
InitiativeManager
- classarcgis.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. Userscall 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.
USAGEEXAMPLE:Addaninitiativesuccessfullyinitiative1=myHub.initiatives.add(title='Vision Zero Analysis')initiative1.item
- clone(initiative,title=None)
Clone allows for the creation of an initiative that is derived from the current initiative.
Note
If both yourorigin_hub anddestination_hub are Hub Basic organizations, please use theclone method supported under the
SiteManager
class.Parameter
Description
initiative
Required
Site
object of site to be cloned.title
Optional String.
- Returns:
Initiative
object
USAGEEXAMPLE:Cloneaninitiativeinanotherorganization#Connect to Hubhub_origin=gis1.hubhub_destination=gis2.hub#Fetch initiativeinitiative1=hub_origin.initiatives.get('itemid12345')#Clone in another Hubinitiative_cloned=hub_destination.initiatives.clone(initiative1,origin_hub=hub_origin)initiative_cloned.itemUSAGEEXAMPLE:Cloneinitiativeinthesameorganizationmyhub=gis.hubinitiative1=myhub.initiatives.get('itemid12345')initiative2=myhub.initiatives.clone(initiative1,title='New Initiative')
- get(initiative_id:str)→str
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.
USAGEEXAMPLE:Fetchaninitiativesuccessfullyinitiative1=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
- classarcgis.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. Userscall 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.
USAGEEXAMPLE:AddanopendatasiteinHubsuccessfullysite1=myHub.sites.add(title='My first site')site1.item
USAGEEXAMPLE:AddanEnterprisesitesuccessfullyenterprise_site=portal_gis.sites.add(title=title)enterprise_site.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 theinitiatives.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:str)→Site
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.
USAGEEXAMPLE:Fetchasitesuccessfullysite1=myHub.sites.get('itemId12345')site1.item
- get_by_domain(domain_url:str)→Site|None
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 canfetch ArcGIS Online sites by url, and if you have signed into an ArcGISEnterprise Instance, only sites on premise will be available.
USAGEEXAMPLE:Fetchasitesuccessfullysite1=myHub.sites.get_by_domain('opendata.dc.gov')site1.item
- search(title:str|None=None,owner:str|None=None,created:str|None=None,modified:str|None=None,tags:str|None=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
- classarcgis.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. Userscall methods on this ‘pages’ object to manipulate (add, get, search, etc) pages for a site.
- add(title:str,site=None)→Page
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.
USAGEEXAMPLE:Addapagetoasitesuccessfullypage1=mySite.pages.add(title='My first page')page1.item
USAGEEXAMPLE:Addapagesuccessfullypage2=myHub.pages.add(title='My second page',site=mySite)page2.item
- clone(page:Page,site=None)→Page
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.
USAGEEXAMPLE:Cloneapagetoasitesuccessfully#Fetch pagepage1=myhub.pages.get('itemId12345')page1.item#Clone itpage2=mySite.pages.clone(page1)page2.item
- get(page_id:str)→Page
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.
USAGEEXAMPLE:Fetchapagesuccessfullypage1=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).
USAGEEXAMPLE:LinkapagesuccessfullyforspecificsitemySite.pages.link(page_id='itemId12345')>>True
USAGEEXAMPLE:LinkapagesuccessfullyforsiteobjectpassedasparammyHub.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:Page,site=None)→bool
Unlinks the page from the specific site.
Note
This method will only detach the page from the site. In order to remove links to thispage from the site’s UI, you will have to manually remove it from the site throughthe 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).
USAGEEXAMPLE:UnlinkapagesuccessfullyfromspecificsitemySite.pages.unlink(page_id='itemId12345')>>True
USAGEEXAMPLE:UnlinkapagesuccessfullyfromsiteobjectpassedasparammyHub.pages.unlink(page_id='itemId12345',site=mySite)>>True
EventManager
- classarcgis.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. Userscall methods on this ‘events’ object to manipulate (add, search, get_map etc) eventsof a particular Hub.
- add(event_properties:dict)→Event
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 keysname andcontact for each organizer’sname and email. Default values are name, email, username of event creator.
sponsors
Optional list of dictionary of keysname andcontact for each sponsor’sname and contact.
- Returns:
Event if successfully added.
USAGEEXAMPLE:Addaneventsuccessfullyevent_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:int)→Event
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.