arcgis.apps.hub module¶
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_Indicators = a_Initiative.indicators.search()
myEvents = myHub.events.search()
Hub¶
- class arcgis.apps.hub.Hub(gis)¶
Entry point into the Hub module. Lets you access an individual hub and its components.
Argument
Description
url
Required string. If no URL is provided by user while connecting to the GIS, then the URL will be ArcGIS Online.
username
Optional string as entered while connecting to GIS. The login user name (case-sensitive).
password
Optional string as entered while connecting to GIS. If a username is provided, a password is expected. This is case-sensitive. If the password is not provided, the user is prompted in the interactive dialog.
- 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 enterprise_org_url¶
Returns the AGOL org url of the Enterprise Organization associated with this Premium Hub.
- property events¶
- property initiatives¶
- property pages¶
- property sites¶
Initiative¶
- class arcgis.apps.hub.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. ===================== ==================================================================== Argument Description ——————— ——————————————————————– items_list Required list. A list of Item or item ids to add to the initiative ===================== ====================================================================
- property all_events¶
- property collab_group_id¶
Getter/Setter for the groupId for the collaboration group
- property content_group_id¶
Returns the groupId for the content group
- 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
- property description¶
Returns the initiative description
- property followers¶
- property followers_group_id¶
Returns the groupId for the followers group
- property itemid¶
Returns the item id of the initiative item
- property owner¶
Returns the owner of the initiative item
- 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.
Argument
Description
target_owner
Required string. The new desired owner of the initiative.
Shares an initiative and associated site with the specified list of groups.
Argument
Description
everyone
Optional boolean. Default is False, don’t share with everyone.
org
Optional boolean. Default is False, don’t share with the organization.
groups
Optional list of group ids as strings, or a list of arcgis.gis.Group objects, or a comma-separated list of group IDs.
allow_members_to_edit
Optional boolean. Default is False, to allow item to be shared with groups that allow shared update
- Returns
A dictionary with key “notSharedWith” containing array of groups with which the items could not be shared.
- property site_id¶
Returns the itemid of the initiative site
- property site_url¶
Getter/Setter for the url of the initiative site
- property sites¶
- property snippet¶
Getter/Setter for the initiative snippet
- property tags¶
Returns the tags of the initiative item
- property title¶
Returns the title of the initiative item
Stops sharing of the initiative and its associated site with the specified list of groups.
Argument
Description
groups
Optional 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, data=None, thumbnail=None, metadata=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.
Argument
Description
initiative_properties
Required dictionary. See URL below for the keys and values.
data
Optional string. Either a path or URL to the data.
thumbnail
Optional string. Either a path or URL to a thumbnail image.
metadata
Optional string. Either a path or URL to the metadata.
To find the list of applicable options for argument initiative_properties - https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#arcgis.gis.Item.update
- 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
- property url¶
Returns the url of the initiative site
Indicator¶
Event¶
- class arcgis.apps.hub.Event(gis, eventObject)¶
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.
- property access¶
Returns access permissions of the event
- property address¶
Returns the street address for the venue of the event
- property attendance¶
Returns attendance count for a past event
- property capacity¶
Returns attendance capacity for attendees of the event
- property creator¶
Returns creator of the event
- 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
- property description¶
Returns description of the event
- property end_date¶
Returns end date of the event in milliseconds since UNIX epoch
- property event_id¶
Returns the unique identifier of the event
- property geometry¶
Returns co-ordinates of the event location
- property group_id¶
Returns groupId for the event
- property initiative_id¶
Returns the initiative id of the initiative the event belongs to
- property is_cancelled¶
Check if event is Cancelled
- property organizers¶
Returns the name and email of the event organizers
- property start_date¶
Returns start date of the event in milliseconds since UNIX epoch
- property title¶
Returns the title of the event
- 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
- property venue¶
Returns the location of the event
InitiativeManager¶
- class arcgis.apps.hub.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, data=None, thumbnail=None)¶
Adds a new initiative to the Hub. =============== ==================================================================== Argument Description ————— ——————————————————————– title Required string. ————— ——————————————————————– description Optional string. ————— ——————————————————————– site Optional Site object. ————— ——————————————————————– data Optional string. Either a path or URL to the data. ————— ——————————————————————– thumbnail Optional string. Either a path or URL to a thumbnail image. =============== ====================================================================
- Returns
The initiative 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 ~arcgis.apps.sites.SiteManager class.
Argument
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.
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.
Argument
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(scope=None, title=None, owner=None, created=None, modified=None, tags=None)¶
Searches for initiatives.
Argument
Description
scope
Optional string. Defines the scope of search. Valid values are ‘official’, ‘community’ or ‘all’.
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 initiatives.
IndicatorManager¶
EventManager¶
- class arcgis.apps.hub.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.
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.
- get(event_id)¶
Get the event for the specified event_id.
Argument
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.
Argument
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.