├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── enhancement_request.md ├── Customer examples └── DevSummit2022 demo of the arcgishub.ipynb ├── LICENSE ├── README.md ├── arcgishub ├── __init__.py ├── _store │ ├── init-sites-data.json │ ├── pages-data.json │ └── sites-data.json ├── discussions.py ├── events.py ├── hub.py ├── indicators.py ├── initiatives.py ├── pages.py └── sites.py ├── build ├── bld.bat ├── build.sh ├── meta.yaml └── setup.py ├── examples ├── .ipynb_checkpoints │ └── Working with initiatives-checkpoint.ipynb ├── For arcgis library │ ├── hub00-Introduction to Hub.ipynb │ ├── hub01-Working with Initiatives.ipynb │ ├── hub02-Working with Indicators.ipynb │ └── hub03-Working with Events.ipynb └── For arcgishub library │ ├── .ipynb_checkpoints │ ├── Accessing events and plotting them on a map-checkpoint.ipynb │ ├── Accessing initiatives-checkpoint.ipynb │ ├── Accessing sites-checkpoint.ipynb │ ├── Adding, updating and deleting sites-checkpoint.ipynb │ ├── Adding, updating, deleting events-Copy1-checkpoint.ipynb │ ├── Adding, updating, deleting events-checkpoint.ipynb │ ├── Adding, updating, deleting initiatives-checkpoint.ipynb │ ├── Change ownership of initiative to another user-checkpoint.ipynb │ ├── Cloning an initiative in another org-checkpoint.ipynb │ ├── Cloning an initiative in the same org-checkpoint.ipynb │ ├── Cloning sites from ArcGIS Hub to Enterprise-checkpoint.ipynb │ ├── Cloning sites within the same org-checkpoint.ipynb │ ├── Searching and Filtering content from your site-checkpoint.ipynb │ ├── Site layout editing -checkpoint.ipynb │ ├── Working with Events-Hub-checkpoint.ipynb │ ├── Working with Initiatives-Hub-checkpoint.ipynb │ └── Working with pages of a site-checkpoint.ipynb │ ├── Accessing events and plotting them on a map.ipynb │ ├── Accessing initiatives.ipynb │ ├── Accessing sites.ipynb │ ├── Adding, updating and deleting sites.ipynb │ ├── Adding, updating, deleting events.ipynb │ ├── Adding, updating, deleting initiatives.ipynb │ ├── Change ownership of initiative to another user.ipynb │ ├── Cloning an initiative in another org.ipynb │ ├── Cloning an initiative in the same org.ipynb │ ├── Cloning sites from ArcGIS Hub to Enterprise.ipynb │ ├── Cloning sites within the same org.ipynb │ ├── Page layout editing .ipynb │ ├── Reassign initiative to another user.ipynb │ ├── Searching and Filtering content from your site.ipynb │ ├── Sharing and unsharing initiatives.ipynb │ ├── Site Theme Editing.ipynb │ ├── Site layout editing .ipynb │ ├── Working with Discussions.ipynb │ └── Working with pages of a site.ipynb ├── requirements.txt ├── setup.py └── tests └── Discussions_Tests.ipynb /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report the issue you are observing here for quick resolution. 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | ** Steps To Reproduce this behavior** 14 | 1. Go to '...' 15 | 2. Click on '....' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Observed behavior** 23 | A clear and concise description of what you observe is happening. 24 | 25 | **Screenshots** 26 | Add screenshots to help demonstrate the code snippet and resulting error. 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement request 3 | about: Suggest an idea for an enhancement to an existing feature 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 |   Copyright 2018 Esri 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # arcgishub 2 | * The `arcgishub` package acts as the Python interface to ArcGIS Hub. It aims to serve both, the core team and community user-base of Hub by allowing automation of several Hub worksflows and simplifying the use of the Hub information model. 3 | * The library now equips users with tools needed to work with the __Sites__ in your Hub or Enterprise organization. You can create new sites and pages, search for existing sites and pages, as well as edit their layout and clone them, not only within the same organization, but over to different organizations as well. 4 | * It is built over the `arcgis` Python API. Ensure you are using the most updated version of the `arcgis` API to use `arcgishub`. Click [here](https://developers.arcgis.com/python/) to learn more about the `arcgis` API. 5 | * The intended UI for this API is the Jupyter Notebook development environment. 6 | * This API is built to work with Sites in Enterprise versions >= 10.8 7 | 8 | In order to install Python, install the bundle that comes with the Anaconda distribution (Refer [this](https://www.anaconda.com/distribution/)) 9 | 10 | ### Steps to install 11 | 12 | Execute the following command in the terminal 13 | 14 | ``` pip install -e git+https://github.com/esri/hub-py.git#egg=arcgishub ``` 15 | 16 | Once installed, test it by launching an instance of Jupyter Notebook and importing the package 17 | 18 | ``` from arcgishub import hub ``` 19 | 20 | 21 | ### Steps to upgrade package 22 | 23 | Execute the following command in the terminal 24 | 25 | ``` pip install -e git+https://github.com/esri/hub-py.git#egg=arcgishub ``` 26 | 27 | Once installed, test it by launching an instance of Jupyter Notebook and importing the package 28 | 29 | ``` from arcgishub import hub ``` 30 | 31 | Test if the version has been upgraded by following with the command 32 | 33 | ```python 34 | import arcgishub 35 | arcgishub.__version__ 36 | ``` 37 | 38 | 39 | ### Getting Started 40 | 41 | The first step to interacting with `arcgishub` is creating an instance of a Hub and exploring all that it contains. 42 | For example: 43 | 44 | ```python 45 | from arcgishub import hub 46 | myHub = hub.Hub("https://cityx.maps.arcgis.com", username, password) # or the url of your ArcGIS Online organization 47 | initiatives = myHub.initiatives.search() 48 | print(initiatives) 49 | ``` 50 | 51 | fetches a list containing all the initiatives within this Hub. Click [here](https://github.com/esri/hub-py/wiki) for more information and API reference about the functionality supported. 52 | 53 | ### User Guides 54 | 55 | Example notebooks for using this API to work with your Hub are provided in the [examples](https://github.com/esri/hub-py/tree/master/examples) directory. 56 | 57 | If you are working with `arcgishub` >=v2.1.0, you will find the above examples and functionality supported in this API under the [For arcgishub](https://github.com/esri/hub-py/tree/master/examples/For%20arcgishub) folder. 58 | 59 | Older versions of this API can also be found in the [ArcGIS API for Python](https://developers.arcgis.com/python/). You can find user guides to access Hub using it, under the [For ArcGIS API for Python](https://github.com/esriesri/hub-py/tree/master/examples/For%20ArcGIS%20API%20for%20Python) subdirectory. 60 | 61 | ### Development 62 | 63 | Install requirements: `pip install -r requirements.txt` 64 | 65 | 66 | ### Reporting issues and feedback 67 | 68 | We strongly encourage you to provide feedback and report issues in implementation, under GitHub [issues](https://github.com/esri/hub-py/issues) for this repo. 69 | 70 | Under the `New Issue` button on that page, you will find an option to add a Bug or Enhancement report along with guidelines. Issues reported via our Github repository will be prioritized in subsequent changes. 71 | Report a bug when you observe unexpected or flawed behavior while working with our API. Report an Enhancement when you would like for a particular Hub object to also support new or improved capabilities within hub-py. 72 | -------------------------------------------------------------------------------- /arcgishub/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '2.2.0' -------------------------------------------------------------------------------- /arcgishub/_store/pages-data.json: -------------------------------------------------------------------------------- 1 | {"source": "PAGEEDITOR","folderId": null,"values": {"sites": [],"layout": {"sections": [{"containment": "fixed","isFooter": false,"style": {"background": {"isFile": false,"isUrl": true,"state": "","display": { },"transparency": 0,"position": {"x": "center","y": "center"},"color": "transparent"},"color": "#4c4c4c"},"rows": [{"cards": [{"component": {"name": "markdown-card","settings": {"markdown": "

Our Community

Use our community's public platform for exploring and downloading open data, discovering and building apps, and engaging to solve important local issues. Here we will provide an explanation on the Open Data we are sharing for our community, how to understand it, and for what you might use it. Together we can make a great, well-connected community!

","schemaVersion": 1}},"width": 12,"showEditor": false}]}]},{"containment": "fixed","isFooter": false,"style": {"background": {"isFile": false,"isUrl": true,"state": "","display": { },"transparency": 0,"position": {"x": "center","y": "center"},"color": "#faf2de"},"color": "#4c4c4c"},"rows": [{"cards": [{"component": {"name": "image-card","settings": {"src": "","fileSrc": "","cropSrc": "","alt": "Community","caption": "","captionAlign": "center","hyperlink": "","hyperlinkTabOption": "new","isUrl": true,"isFile": false,"state": "valid","display": {"position": {"x": "center","y": "center"},"reflow": false}}},"width": 6},{"component": {"name": "markdown-card","settings": {"markdown": "

Intro

Everyone has a story to tell and we are no different. This is the description of a particular policy that we will be sharing with you and the Open Data behind it.

Go to the Data

","schemaVersion": 1}},"width": 6,"showEditor": false}]}]},{"containment": "fixed","isFooter": false,"style": {"background": {"isFile": false,"isUrl": true,"state": "","display": { },"transparency": 0,"position": {"x": "center","y": "center"},"color": "transparent"},"color": "#4C4C4C"},"rows": [{"cards": [{"component": {"name": "markdown-card","settings": {"markdown": "

Where We're Going

Here are the next steps and how we need your help to improve this data:

","schemaVersion": 1}},"width": 12,"showEditor": false}]}]},{"containment": "fixed","isFooter": false,"style": {"background": {"isFile": false,"isUrl": true,"state": "","display": { },"transparency": 0,"position": {"x": "center","y": "center"},"color": "transparent"},"color": "#4c4c4c"},"rows": [{"cards": [{"component": {"name": "markdown-card","settings": {"markdown": "","schemaVersion": 1}},"width": 12,"showEditor": false}]}]},{"containment": "fixed","isFooter": false,"style": {"background": {"isFile": false,"isUrl": true,"state": "","display": { },"transparency": 0,"position": {"x": "center","y": "center"},"color": "#f3f3ee","image": ""},"color": "#333333"},"rows": [{"cards": [{"component": {"name": "markdown-card","settings": {"markdown": "


Copyright 2016. Your Organization.

","schemaVersion": 1}},"width": 4,"showEditor": false},{"component": {"name": "markdown-card","settings": {"markdown": "

About

","schemaVersion": 1}},"width": 4,"showEditor": false},{"component": {"name": "markdown-card","settings": {"markdown": "

Contact Us

","schemaVersion": 1}},"width": 4,"showEditor": false}]}]}]},"updatedAt": "","updatedBy": ""}} -------------------------------------------------------------------------------- /arcgishub/hub.py: -------------------------------------------------------------------------------- 1 | from arcgis.gis import GIS 2 | from arcgis._impl.common._mixins import PropertyMap 3 | from arcgishub.sites import SiteManager, Site 4 | from arcgishub.pages import PageManager 5 | from arcgishub.initiatives import Initiative, InitiativeManager 6 | from arcgishub.events import Event, EventManager 7 | from arcgishub import discussions 8 | from arcgishub.discussions import ChannelManager, PostManager 9 | from datetime import datetime 10 | from collections import OrderedDict 11 | 12 | def _lazy_property(fn): 13 | '''Decorator that makes a property lazy-evaluated. 14 | ''' 15 | # http://stevenloria.com/lazy-evaluated-properties-in-python/ 16 | attr_name = '_lazy_' + fn.__name__ 17 | 18 | @property 19 | def _lazy_property(self): 20 | if not hasattr(self, attr_name): 21 | setattr(self, attr_name, fn(self)) 22 | return getattr(self, attr_name) 23 | return _lazy_property 24 | 25 | class Hub(object): 26 | """ 27 | Entry point into the Hub module. Lets you access an individual hub and its components. 28 | 29 | ================ =============================================================== 30 | **Argument** **Description** 31 | ---------------- --------------------------------------------------------------- 32 | url Required string. If no URL is provided by user while connecting 33 | to the GIS, then the URL will be ArcGIS Online. 34 | ---------------- --------------------------------------------------------------- 35 | username Optional string as entered while connecting to GIS. The login user name 36 | (case-sensitive). 37 | ---------------- --------------------------------------------------------------- 38 | password Optional string as entered while connecting to GIS. If a username is 39 | provided, a password is expected. This is case-sensitive. If the password 40 | is not provided, the user is prompted in the interactive dialog. 41 | ---------------- --------------------------------------------------------------- 42 | key_file Optional string. The file path to a user's key certificate for PKI 43 | authentication 44 | ---------------- --------------------------------------------------------------- 45 | cert_file Optional string. The file path to a user's certificate file for PKI 46 | authentication. If a PFX or P12 certificate is used, a password is required. 47 | If a PEM file is used, the key_file is required. 48 | ---------------- --------------------------------------------------------------- 49 | verify_cert Optional boolean. If a site has an invalid SSL certificate or is 50 | being accessed via the IP or hostname instead of the name on the 51 | certificate, set this value to False. This will ensure that all 52 | SSL certificate issues are ignored. 53 | The default is True. 54 | **Warning** Setting the value to False can be a security risk. 55 | ---------------- --------------------------------------------------------------- 56 | set_active Optional boolean. The default is True. If True, the GIS object 57 | will be used as the default GIS object throughout the whole 58 | scripting session. 59 | ---------------- --------------------------------------------------------------- 60 | client_id Optional string. Used for OAuth authentication. This is the 61 | client ID value. 62 | ---------------- --------------------------------------------------------------- 63 | profile Optional string. the name of the profile that the user wishes to use 64 | to authenticate, if set, the identified profile will be used to login 65 | to the specified GIS. 66 | ================ =============================================================== 67 | """ 68 | 69 | def __init__(self, url=None, username=None, password=None, key_file=None, cert_file=None, 70 | verify_cert=True, set_active=True, client_id=None, profile=None): 71 | #self.gis = gis 72 | self._username = username 73 | self._password = password 74 | if url==None: 75 | self.url = 'https://www.arcgis.com' 76 | else: 77 | self.url = url 78 | self.gis = GIS(self.url, self._username, self._password, key_file, cert_file, verify_cert, 79 | set_active, client_id, profile) 80 | try: 81 | self._gis_id = self.gis.properties.id 82 | except AttributeError: 83 | self._gis_id = None 84 | 85 | @property 86 | def _hub_enabled(self): 87 | """ 88 | Returns True if Hub is enabled on this org 89 | """ 90 | try: 91 | self.gis.properties.portalProperties["hub"]["enabled"] 92 | return True 93 | except: 94 | return False 95 | 96 | @property 97 | def _hub_environment(self): 98 | """ 99 | Returns the hub url corresponding to the dev/qa/prod environment. 100 | """ 101 | url = self.gis.url 102 | print(f"_hub_environment: {url}") 103 | if 'devext' in url: 104 | return 'hubdev.arcgis.com' 105 | elif 'mapsqa' in url or 'qaext' in url: # mapsqa is for orgs, but qaext is for front door 106 | return 'hubqa.arcgis.com' 107 | else: 108 | return 'hub.arcgis.com' 109 | 110 | @property 111 | def enterprise_org_id(self): 112 | """ 113 | Returns the AGOL org id of the Enterprise Organization associated with this Hub. 114 | """ 115 | 116 | if self._hub_enabled: 117 | try: 118 | _e_org_id = self.gis.properties.portalProperties.hub.settings.enterpriseOrg.orgId 119 | return _e_org_id 120 | except AttributeError: 121 | try: 122 | if self.gis.properties.subscriptionInfo.companionOrganizations.type=='Enterprise': 123 | return 'Enterprise org id is not available' 124 | except: 125 | return self._gis_id 126 | else: 127 | raise Exception("Hub does not exist or is inaccessible.") 128 | 129 | @property 130 | def community_org_id(self): 131 | """ 132 | Returns the AGOL org id of the Community Organization associated with this Hub. 133 | """ 134 | if self._hub_enabled: 135 | try: 136 | _c_org_id = self.gis.properties.portalProperties.hub.settings.communityOrg.orgId 137 | return _c_org_id 138 | except AttributeError: 139 | try: 140 | if self.gis.properties.subscriptionInfo.companionOrganizations.type=='Community': 141 | return 'Community org id is not available' 142 | except: 143 | return self._gis_id 144 | else: 145 | raise Exception("Hub does not exist or is inaccessible.") 146 | 147 | @property 148 | def enterprise_org_url(self): 149 | """ 150 | Returns the AGOL org url of the Enterprise Organization associated with this Hub. 151 | """ 152 | try: 153 | self.gis.properties.portalProperties.hub 154 | try: 155 | self.gis.properties.portalProperties.hub.settings.enterpriseOrg 156 | try: 157 | _url = self.gis.properties.publicSubscriptionInfo.companionOrganizations[0]['organizationUrl'] 158 | except: 159 | _url = self.gis.properties.subscriptionInfo.companionOrganizations[0]['organizationUrl'] 160 | return "https://"+_url 161 | except AttributeError: 162 | return self.gis.url 163 | except AttributeError: 164 | print("Hub does not exist or is inaccessible.") 165 | raise 166 | 167 | @property 168 | def community_org_url(self): 169 | """ 170 | Returns the AGOL org id of the Community Organization associated with this Hub. 171 | """ 172 | try: 173 | self.gis.properties.portalProperties.hub 174 | try: 175 | self.gis.properties.portalProperties.hub.settings.communityOrg 176 | try: 177 | _url = self.gis.properties.publicSubscriptionInfo.companionOrganizations[0]['organizationUrl'] 178 | except: 179 | _url = self.gis.properties.subscriptionInfo.companionOrganizations[0]['organizationUrl'] 180 | return "https://"+_url 181 | except AttributeError: 182 | return self.gis.url 183 | except: 184 | print("Hub does not exist or is inaccessible.") 185 | raise 186 | 187 | @_lazy_property 188 | def initiatives(self): 189 | """ 190 | The resource manager for Hub initiatives. See :class:`~arcgis.apps.hub.InitiativeManager`. 191 | """ 192 | if self._hub_enabled: 193 | return InitiativeManager(self) 194 | else: 195 | raise Exception("Initiatives are only available with Hub Premium. Please upgrade to Hub Premium to use this feature.") 196 | 197 | @_lazy_property 198 | def events(self): 199 | """ 200 | The resource manager for Hub events. See :class:`~arcgis.apps.hub.EventManager`. 201 | """ 202 | if self._hub_enabled: 203 | return EventManager(self) 204 | else: 205 | raise Exception("Events is only available with Hub Premium. Please upgrade to Hub Premium to use this feature.") 206 | 207 | @_lazy_property 208 | def sites(self): 209 | """ 210 | The resource manager for Hub sites. See :class:`~hub.sites.SiteManager`. 211 | """ 212 | return SiteManager(self) 213 | 214 | @_lazy_property 215 | def pages(self): 216 | """ 217 | The resource manager for Hub pages. See :class:`~hub.sites.PageManager`. 218 | """ 219 | return PageManager(self.gis) 220 | 221 | @_lazy_property 222 | def discussions(self): 223 | """ 224 | The resource manager for Hub Discussions. 225 | """ 226 | discussions.posts = PostManager(self) 227 | discussions.channels = ChannelManager(self) 228 | return discussions -------------------------------------------------------------------------------- /build/bld.bat: -------------------------------------------------------------------------------- 1 | "%PYTHON%" D:/Projects/hub-py/setup.py install --single-version-externally-managed --record=record.txt 2 | if errorlevel 1 exit 1 -------------------------------------------------------------------------------- /build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | $PYTHON setup.py install --single-version-externally-managed --record=record.txt # Python command to install the script. -------------------------------------------------------------------------------- /build/meta.yaml: -------------------------------------------------------------------------------- 1 | # This file created by conda-build 2.0.1 2 | # meta.yaml template originally from: 3 | # e:\share\conda-project\conda-packages\arcgis-api 4 | # ------------------------------------------------ 5 | 6 | package: 7 | name: arcgishub 8 | version: '1.0.0' 9 | source: 10 | path: D:/Projects/hub-py/src 11 | build: 12 | number: '1' 13 | requirements: 14 | build: 15 | - python 16 | - setuptools 17 | - six 18 | run: 19 | - python 20 | - six 21 | #test: 22 | #imports: 23 | # - arcgis.gis 24 | about: 25 | #home: https://developers.arcgis.com/python 26 | license: Esri Master License Agreement (MLA) 27 | summary: ArcGIS Hub Python API -------------------------------------------------------------------------------- /build/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from codecs import open 3 | from os import path 4 | 5 | here = path.abspath(path.dirname(__file__)) 6 | 7 | setup( 8 | name='arcgishub', 9 | 10 | # Versions should comply with PEP440. For a discussion on single-sourcing 11 | # the version across setup.py and the project code, see 12 | # https://packaging.python.org/en/latest/single_source_version.html 13 | 14 | version='1.0.0', 15 | description='ArcGIS Hub Python API', 16 | long_description='Python API to automate your Hub processes', 17 | #url='http://pypi.python.org/pypi/TowelStuff/', 18 | 19 | #Author details 20 | author='Esri', 21 | #author_email='jrh@example.com', 22 | 23 | # Choose your license 24 | license='Proprietary License', 25 | 26 | # See https://pypi.python.org/pypi?%3Aaction=list_classifiers 27 | classifiers=[ 28 | # How mature is this project? Common values are 29 | # 3 - Alpha 30 | # 4 - Beta 31 | # 5 - Production/Stable 32 | 'Development Status :: 3', 33 | 34 | # Indicate who your project is intended for 35 | 'Intended Audience :: Developers, Hub Customers', 36 | 37 | # Pick your license as you wish (should match "license" above) 38 | 'License :: Other/Proprietary License', 39 | 40 | # Specify the Python versions you support here. In particular, ensure 41 | # that you indicate whether you support Python 2, Python 3 or both. 42 | 'Programming Language :: Python :: 3.6', 43 | ], 44 | 45 | # What does your project relate to? 46 | keywords='gis geographic spatial hub', 47 | 48 | packages=find_packages(), 49 | 50 | # List run-time dependencies here. These will be installed by pip when 51 | # your project is installed. For an analysis of "install_requires" vs pip's 52 | # requirements files see: 53 | # https://packaging.python.org/en/latest/requirements.html 54 | install_requires=['six'], 55 | ) -------------------------------------------------------------------------------- /examples/For arcgis library/hub03-Working with Events.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Working with Events" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "ArcGIS Hub supports engagement through in-person and virtual events.\n", 15 | "\n", 16 | "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.\n", 17 | "\n", 18 | "A Hub has many Events that can be associated with an Initiative." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from arcgis.gis import GIS" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "gis = GIS(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 3, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "myHub = gis.hub" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "metadata": {}, 59 | "source": [ 60 | "#### Searching for events\n", 61 | "\n", 62 | "You can search for `events` of a Hub using the following parameters:\n", 63 | "* `initiative_id`\n", 64 | "* `title`\n", 65 | "* `location`\n", 66 | "* `organizer_name`" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 4, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "data": { 76 | "text/plain": [ 77 | "[,\n", 78 | " ,\n", 79 | " ,\n", 80 | " ,\n", 81 | " ,\n", 82 | " ,\n", 83 | " ,\n", 84 | " ]" 85 | ] 86 | }, 87 | "execution_count": 4, 88 | "metadata": {}, 89 | "output_type": "execute_result" 90 | } 91 | ], 92 | "source": [ 93 | "myHub.events.search()" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 5, 99 | "metadata": {}, 100 | "outputs": [ 101 | { 102 | "data": { 103 | "text/plain": [ 104 | "[,\n", 105 | " ,\n", 106 | " ,\n", 107 | " ]" 108 | ] 109 | }, 110 | "execution_count": 5, 111 | "metadata": {}, 112 | "output_type": "execute_result" 113 | } 114 | ], 115 | "source": [ 116 | "myHub.events.search(title='Test')" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 6, 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "data": { 126 | "text/plain": [ 127 | "" 128 | ] 129 | }, 130 | "execution_count": 6, 131 | "metadata": {}, 132 | "output_type": "execute_result" 133 | } 134 | ], 135 | "source": [ 136 | "event1 = myHub.events.search(initiative_id='30d22500fdb54e9699f97c3b74523394')[0]\n", 137 | "event1" 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "metadata": {}, 143 | "source": [ 144 | "#### Accessing properties of an event" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "You can access properties of an event as follows:" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 7, 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "data": { 161 | "text/plain": [ 162 | "1540654200000" 163 | ] 164 | }, 165 | "execution_count": 7, 166 | "metadata": {}, 167 | "output_type": "execute_result" 168 | } 169 | ], 170 | "source": [ 171 | "event1.start_date" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 8, 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "data": { 181 | "text/plain": [ 182 | "'caf0f1b59f084ff5aae6ecc8ee315dcf'" 183 | ] 184 | }, 185 | "execution_count": 8, 186 | "metadata": {}, 187 | "output_type": "execute_result" 188 | } 189 | ], 190 | "source": [ 191 | "event1.siteid" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 9, 197 | "metadata": {}, 198 | "outputs": [ 199 | { 200 | "data": { 201 | "text/plain": [ 202 | "'[{\"name\":\"Justin Prather\",\"contact\":\"j.prather@esri.com\"}]'" 203 | ] 204 | }, 205 | "execution_count": 9, 206 | "metadata": {}, 207 | "output_type": "execute_result" 208 | } 209 | ], 210 | "source": [ 211 | "event1.organizers" 212 | ] 213 | }, 214 | { 215 | "cell_type": "markdown", 216 | "metadata": {}, 217 | "source": [ 218 | "#### Visualize all events on a map" 219 | ] 220 | }, 221 | { 222 | "cell_type": "code", 223 | "execution_count": 10, 224 | "metadata": {}, 225 | "outputs": [ 226 | { 227 | "data": { 228 | "application/vnd.jupyter.widget-view+json": { 229 | "model_id": "8f6f92c26ce141a1a379f137277dd763", 230 | "version_major": 2, 231 | "version_minor": 0 232 | }, 233 | "text/plain": [ 234 | "MapView(layout=Layout(height='400px', width='100%'), zoom=2.0)" 235 | ] 236 | }, 237 | "metadata": {}, 238 | "output_type": "display_data" 239 | }, 240 | { 241 | "data": { 242 | "text/html": [ 243 | "
" 244 | ], 245 | "text/plain": [ 246 | "" 247 | ] 248 | }, 249 | "metadata": {}, 250 | "output_type": "display_data" 251 | } 252 | ], 253 | "source": [ 254 | "myHub.events.get_map()" 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "![event_map](https://user-images.githubusercontent.com/13968196/54644431-a31e2d80-4a6f-11e9-845a-96998ef6b082.PNG)" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": null, 267 | "metadata": {}, 268 | "outputs": [], 269 | "source": [] 270 | } 271 | ], 272 | "metadata": { 273 | "kernelspec": { 274 | "display_name": "Python 3", 275 | "language": "python", 276 | "name": "python3" 277 | }, 278 | "language_info": { 279 | "codemirror_mode": { 280 | "name": "ipython", 281 | "version": 3 282 | }, 283 | "file_extension": ".py", 284 | "mimetype": "text/x-python", 285 | "name": "python", 286 | "nbconvert_exporter": "python", 287 | "pygments_lexer": "ipython3", 288 | "version": "3.7.1" 289 | } 290 | }, 291 | "nbformat": 4, 292 | "nbformat_minor": 2 293 | } 294 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Accessing events and plotting them on a map-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Accessign events in your Hub and plotting them on a map" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "ArcGIS Hub supports engagement through in-person and virtual events.\n", 15 | "\n", 16 | "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.\n", 17 | "\n", 18 | "A Hub has many Events that can be associated with an Initiative." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from arcgishub import hub" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "myhub = hub.Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "### Searching for events\n", 52 | "\n", 53 | "You can search for `events` of a Hub using the following parameters:\n", 54 | "* `initiative_id`\n", 55 | "* `title`\n", 56 | "* `venue`\n", 57 | "* `organizer_name`" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 3, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "[,\n", 69 | " ,\n", 70 | " ,\n", 71 | " ,\n", 72 | " ]" 73 | ] 74 | }, 75 | "execution_count": 3, 76 | "metadata": {}, 77 | "output_type": "execute_result" 78 | } 79 | ], 80 | "source": [ 81 | "all_events = myhub.events.search()\n", 82 | "all_events[:5]" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 4, 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "data": { 92 | "text/plain": [ 93 | "[,\n", 94 | " ,\n", 95 | " ,\n", 96 | " ,\n", 97 | " ,\n", 98 | " ,\n", 99 | " ,\n", 100 | " ,\n", 101 | " ]" 102 | ] 103 | }, 104 | "execution_count": 4, 105 | "metadata": {}, 106 | "output_type": "execute_result" 107 | } 108 | ], 109 | "source": [ 110 | "myhub.events.search(title='Hub')" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 5, 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "data": { 120 | "text/plain": [ 121 | "[,\n", 122 | " ,\n", 123 | " ,\n", 124 | " ,\n", 125 | " ,\n", 126 | " ,\n", 127 | " ,\n", 128 | " ]" 129 | ] 130 | }, 131 | "execution_count": 5, 132 | "metadata": {}, 133 | "output_type": "execute_result" 134 | } 135 | ], 136 | "source": [ 137 | "myhub.events.search(organizer_name='Manushi')" 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "metadata": {}, 143 | "source": [ 144 | "### Fetching an event" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "You can fetch a particular event by passing in the event id to the `get()` method" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 6, 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "data": { 161 | "text/plain": [ 162 | "" 163 | ] 164 | }, 165 | "execution_count": 6, 166 | "metadata": {}, 167 | "output_type": "execute_result" 168 | } 169 | ], 170 | "source": [ 171 | "event1 = myhub.events.get(2)\n", 172 | "event1" 173 | ] 174 | }, 175 | { 176 | "cell_type": "markdown", 177 | "metadata": {}, 178 | "source": [ 179 | "### Accessing properties of an event" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "You can access properties of an event as follows:" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 7, 192 | "metadata": {}, 193 | "outputs": [ 194 | { 195 | "data": { 196 | "text/plain": [ 197 | "1540654200000" 198 | ] 199 | }, 200 | "execution_count": 7, 201 | "metadata": {}, 202 | "output_type": "execute_result" 203 | } 204 | ], 205 | "source": [ 206 | "event1.start_date" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 8, 212 | "metadata": {}, 213 | "outputs": [ 214 | { 215 | "data": { 216 | "text/plain": [ 217 | "'Anacostia Neighborhood Library'" 218 | ] 219 | }, 220 | "execution_count": 8, 221 | "metadata": {}, 222 | "output_type": "execute_result" 223 | } 224 | ], 225 | "source": [ 226 | "event1.venue" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": 9, 232 | "metadata": {}, 233 | "outputs": [ 234 | { 235 | "data": { 236 | "text/plain": [ 237 | "'[{\"name\":\"Justin Prather\",\"contact\":\"j.prather@esri.com\"}]'" 238 | ] 239 | }, 240 | "execution_count": 9, 241 | "metadata": {}, 242 | "output_type": "execute_result" 243 | } 244 | ], 245 | "source": [ 246 | "event1.organizers" 247 | ] 248 | }, 249 | { 250 | "cell_type": "markdown", 251 | "metadata": {}, 252 | "source": [ 253 | "### Visualize all events on a map" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 10, 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "data": { 263 | "application/vnd.jupyter.widget-view+json": { 264 | "model_id": "bdbb1bee693047b0ba907b8f469d091a", 265 | "version_major": 2, 266 | "version_minor": 0 267 | }, 268 | "text/plain": [ 269 | "MapView(layout=Layout(height='400px', width='100%'))" 270 | ] 271 | }, 272 | "metadata": {}, 273 | "output_type": "display_data" 274 | }, 275 | { 276 | "data": { 277 | "text/html": [ 278 | "
" 279 | ], 280 | "text/plain": [ 281 | "" 282 | ] 283 | }, 284 | "metadata": {}, 285 | "output_type": "display_data" 286 | }, 287 | { 288 | "data": { 289 | "text/html": [ 290 | "
" 291 | ], 292 | "text/plain": [ 293 | "" 294 | ] 295 | }, 296 | "metadata": {}, 297 | "output_type": "display_data" 298 | } 299 | ], 300 | "source": [ 301 | "myhub.events.get_map()" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "![event_map](https://user-images.githubusercontent.com/13968196/54644431-a31e2d80-4a6f-11e9-845a-96998ef6b082.PNG)" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [] 317 | } 318 | ], 319 | "metadata": { 320 | "kernelspec": { 321 | "display_name": "Python 3 (ipykernel)", 322 | "language": "python", 323 | "name": "python3" 324 | }, 325 | "language_info": { 326 | "codemirror_mode": { 327 | "name": "ipython", 328 | "version": 3 329 | }, 330 | "file_extension": ".py", 331 | "mimetype": "text/x-python", 332 | "name": "python", 333 | "nbconvert_exporter": "python", 334 | "pygments_lexer": "ipython3", 335 | "version": "3.7.11" 336 | } 337 | }, 338 | "nbformat": 4, 339 | "nbformat_minor": 2 340 | } 341 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Accessing initiatives-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Accessing Initiatives" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Fetching a single initiative\n", 57 | "\n", 58 | "To fetch a particular initiative pass the initiative itemId to the `get` method on `initiatives`" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "walkability_init = myHub.initiatives.get('07fad5be49da45bea02c8f5b0876be24')" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 4, 73 | "metadata": {}, 74 | "outputs": [ 75 | { 76 | "data": { 77 | "text/html": [ 78 | "
\n", 79 | "
\n", 80 | " \n", 81 | " \n", 82 | " \n", 83 | "
\n", 84 | "\n", 85 | "
\n", 86 | " Walkability Assessment \n", 87 | " \n", 88 | "
Assess how walkable your city isHub Initiative by mmajumdar_dcdev\n", 89 | "
Last Modified: June 28, 2019\n", 90 | "
0 comments, 270 views\n", 91 | "
\n", 92 | "
\n", 93 | " " 94 | ], 95 | "text/plain": [ 96 | "" 97 | ] 98 | }, 99 | "execution_count": 4, 100 | "metadata": {}, 101 | "output_type": "execute_result" 102 | } 103 | ], 104 | "source": [ 105 | "walkability_init.item" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "Properties of an initiative can be accessed as follows:" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 5, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "data": { 122 | "text/plain": [ 123 | "'12b8f977ee1e46998c2d8aa39feb15a7'" 124 | ] 125 | }, 126 | "execution_count": 5, 127 | "metadata": {}, 128 | "output_type": "execute_result" 129 | } 130 | ], 131 | "source": [ 132 | "walkability_init.site_id" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "### Searching for initiatives" 140 | ] 141 | }, 142 | { 143 | "cell_type": "markdown", 144 | "metadata": {}, 145 | "source": [ 146 | "You can search for initiatives based on `title`, `owner`, information about when the initiative was `created` and last `modified` or `tags`" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 6, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "[,\n", 158 | " ,\n", 159 | " ,\n", 160 | " ,\n", 161 | " ,\n", 162 | " ,\n", 163 | " ]" 164 | ] 165 | }, 166 | "execution_count": 6, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "myHub.initiatives.search(title='Vision Zero', owner='mmajumdar_dcdev', tags='Hub')" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": {}, 179 | "outputs": [], 180 | "source": [] 181 | } 182 | ], 183 | "metadata": { 184 | "kernelspec": { 185 | "display_name": "Python 3 (ipykernel)", 186 | "language": "python", 187 | "name": "python3" 188 | }, 189 | "language_info": { 190 | "codemirror_mode": { 191 | "name": "ipython", 192 | "version": 3 193 | }, 194 | "file_extension": ".py", 195 | "mimetype": "text/x-python", 196 | "name": "python", 197 | "nbconvert_exporter": "python", 198 | "pygments_lexer": "ipython3", 199 | "version": "3.7.11" 200 | } 201 | }, 202 | "nbformat": 4, 203 | "nbformat_minor": 2 204 | } 205 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Adding, updating, deleting events-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Working with Events" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "ArcGIS Hub supports engagement through in-person and virtual events.\n", 15 | "\n", 16 | "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.\n", 17 | "\n", 18 | "A Hub has many Events that can be associated with an Initiative." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from arcgishub import hub" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "myhub = hub.Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "### Searching for events\n", 52 | "\n", 53 | "You can search for `events` of a Hub using the following parameters:\n", 54 | "* `initiative_id`\n", 55 | "* `title`\n", 56 | "* `venue`\n", 57 | "* `organizer_name`" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 3, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "[,\n", 69 | " ,\n", 70 | " ,\n", 71 | " ,\n", 72 | " ]" 73 | ] 74 | }, 75 | "execution_count": 3, 76 | "metadata": {}, 77 | "output_type": "execute_result" 78 | } 79 | ], 80 | "source": [ 81 | "all_events = myhub.events.search()\n", 82 | "all_events[:5]" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "### Adding a new event" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "You can add a new event by passing the necessary attributes as `event_properties` to the `add()` method.\n", 97 | "\n", 98 | "The required attributes needed for adding an event are:\n", 99 | "* `title`\n", 100 | "* `description`\n", 101 | "* `initiativeId`\n", 102 | "* `venue`\n", 103 | "* `address1`\n", 104 | "* `status`\n", 105 | "* `startDate`\n", 106 | "* `endDate`\n", 107 | "* `isAllDay`\n", 108 | "\n", 109 | "The other optional attributes that can also be provided while creating an event are:\n", 110 | "* `url` if web event\n", 111 | "* `attendance` capacity of the event\n", 112 | "* `status` - public/planned/private\n", 113 | "* `organizers` - dictionary with values for `name`, `contact` (email), `username` (ArcGIS Online username)\n", 114 | "* `sponsors` - - dictionary with values for `name`, `contact` (email/website/Twitter/etc), `username` (ArcGIS Online username)\n", 115 | "* `geometry` - In the absence of this field, the `address1` field is geocoded\n", 116 | "\n", 117 | "Follow through the example below to see how to create an event." 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": 4, 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [ 126 | "event_properties = {\n", 127 | " \"title\":\"Updated event in python\",\n", 128 | " 'description': 'New event in 2022',\n", 129 | " 'initiativeId': 'b4cbdaf65f3c4b55a8fb1f8dcbe0fc3b',\n", 130 | " 'venue': 'ESRI R&D Center',\n", 131 | " 'address1': '1001 19th St N #910, Arlington, VA 22209',\n", 132 | " 'status': 'public',\n", 133 | " 'startDate': 1585356198,\n", 134 | " 'endDate': 1585399398,\n", 135 | " 'isAllDay': 0,\n", 136 | " 'geometry': {'x': -77.06915099999999, 'y': 38.89740599999999}\n", 137 | "}" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 5, 143 | "metadata": {}, 144 | "outputs": [ 145 | { 146 | "data": { 147 | "text/plain": [ 148 | "" 149 | ] 150 | }, 151 | "execution_count": 5, 152 | "metadata": {}, 153 | "output_type": "execute_result" 154 | } 155 | ], 156 | "source": [ 157 | "new_event = myhub.events.add(event_properties)\n", 158 | "new_event" 159 | ] 160 | }, 161 | { 162 | "cell_type": "markdown", 163 | "metadata": {}, 164 | "source": [ 165 | "### Update an event" 166 | ] 167 | }, 168 | { 169 | "cell_type": "markdown", 170 | "metadata": {}, 171 | "source": [ 172 | "In order to update an event, pass the particular attributes that need updating to the `event_properties` parameter" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 6, 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "data": { 182 | "text/plain": [ 183 | "True" 184 | ] 185 | }, 186 | "execution_count": 6, 187 | "metadata": {}, 188 | "output_type": "execute_result" 189 | } 190 | ], 191 | "source": [ 192 | "new_event.update(event_properties={'status':'private'})" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 7, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "data": { 202 | "text/plain": [ 203 | "'private'" 204 | ] 205 | }, 206 | "execution_count": 7, 207 | "metadata": {}, 208 | "output_type": "execute_result" 209 | } 210 | ], 211 | "source": [ 212 | "new_event.access" 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "### Delete an event" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": 11, 225 | "metadata": {}, 226 | "outputs": [ 227 | { 228 | "data": { 229 | "text/plain": [ 230 | "True" 231 | ] 232 | }, 233 | "execution_count": 11, 234 | "metadata": {}, 235 | "output_type": "execute_result" 236 | } 237 | ], 238 | "source": [ 239 | "myhub.events.get(1124).delete()" 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": 12, 245 | "metadata": {}, 246 | "outputs": [ 247 | { 248 | "data": { 249 | "text/plain": [ 250 | "True" 251 | ] 252 | }, 253 | "execution_count": 12, 254 | "metadata": {}, 255 | "output_type": "execute_result" 256 | } 257 | ], 258 | "source": [ 259 | "new_event.delete()" 260 | ] 261 | }, 262 | { 263 | "cell_type": "code", 264 | "execution_count": null, 265 | "metadata": {}, 266 | "outputs": [], 267 | "source": [] 268 | } 269 | ], 270 | "metadata": { 271 | "kernelspec": { 272 | "display_name": "Python 3 (ipykernel)", 273 | "language": "python", 274 | "name": "python3" 275 | }, 276 | "language_info": { 277 | "codemirror_mode": { 278 | "name": "ipython", 279 | "version": 3 280 | }, 281 | "file_extension": ".py", 282 | "mimetype": "text/x-python", 283 | "name": "python", 284 | "nbconvert_exporter": "python", 285 | "pygments_lexer": "ipython3", 286 | "version": "3.7.11" 287 | } 288 | }, 289 | "nbformat": 4, 290 | "nbformat_minor": 2 291 | } 292 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Adding, updating, deleting initiatives-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Adding, updating and deleting Initiatives" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Adding new initiaitve" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "To add a new initiative to your hub, all you do is call the `add` method with the `title` and `description` (optional) for the initiative.\n", 64 | "\n", 65 | "Collaboration and Open Data groups corresponding to the initiative are created as part of the process on initiative creation." 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 3, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "myInitiative = myHub.initiatives.add(title='Python initiative 2022')" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 4, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "data": { 84 | "text/html": [ 85 | "
\n", 86 | "
\n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | "
\n", 91 | "\n", 92 | "
\n", 93 | " Python initiative 2022\n", 94 | " \n", 95 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by mmajumdar_dcdev\n", 96 | "
Last Modified: October 27, 2022\n", 97 | "
0 comments, 0 views\n", 98 | "
\n", 99 | "
\n", 100 | " " 101 | ], 102 | "text/plain": [ 103 | "" 104 | ] 105 | }, 106 | "execution_count": 4, 107 | "metadata": {}, 108 | "output_type": "execute_result" 109 | } 110 | ], 111 | "source": [ 112 | "myInitiative.item" 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "### Updating initiative" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "`description` and `snippet` of an initiative can be updated directly as shown below" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 5, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "myInitiative.snippet = 'Create your own initiative by combining existing applications with a custom site'" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 6, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/html": [ 146 | "
\n", 147 | "
\n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | "
\n", 152 | "\n", 153 | "
\n", 154 | " Python initiative 2022\n", 155 | " \n", 156 | "
Create your own initiative by combining existing applications with a custom siteHub Initiative by mmajumdar_dcdev\n", 157 | "
Last Modified: October 27, 2022\n", 158 | "
0 comments, 0 views\n", 159 | "
\n", 160 | "
\n", 161 | " " 162 | ], 163 | "text/plain": [ 164 | "" 165 | ] 166 | }, 167 | "execution_count": 6, 168 | "metadata": {}, 169 | "output_type": "execute_result" 170 | } 171 | ], 172 | "source": [ 173 | "#Verify\n", 174 | "myInitiative.item" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 7, 180 | "metadata": {}, 181 | "outputs": [ 182 | { 183 | "data": { 184 | "text/plain": [ 185 | "[]" 186 | ] 187 | }, 188 | "execution_count": 7, 189 | "metadata": {}, 190 | "output_type": "execute_result" 191 | } 192 | ], 193 | "source": [ 194 | "myInitiative.tags" 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "To update other properties of an initiative, you can call the `update` method on the particular initiative that accepts initiative properties to be updated as a dictionary" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": 8, 207 | "metadata": {}, 208 | "outputs": [ 209 | { 210 | "data": { 211 | "text/plain": [ 212 | "True" 213 | ] 214 | }, 215 | "execution_count": 8, 216 | "metadata": {}, 217 | "output_type": "execute_result" 218 | } 219 | ], 220 | "source": [ 221 | "myInitiative.update(initiative_properties={'tags': 'Hub, OpenData'})" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 9, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "['Hub', 'OpenData']" 233 | ] 234 | }, 235 | "execution_count": 9, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "#Verify\n", 242 | "myInitiative.tags" 243 | ] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "metadata": {}, 248 | "source": [ 249 | "Refer the [item properties table](https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#arcgis.gis.Item.update) to learn more about `initiative_properties` that can be updated using this function" 250 | ] 251 | }, 252 | { 253 | "cell_type": "markdown", 254 | "metadata": {}, 255 | "source": [ 256 | "### Delete initiative" 257 | ] 258 | }, 259 | { 260 | "cell_type": "markdown", 261 | "metadata": {}, 262 | "source": [ 263 | "To delete an initiative call the `delete` method on the particular initiative" 264 | ] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": 10, 269 | "metadata": {}, 270 | "outputs": [ 271 | { 272 | "data": { 273 | "text/plain": [ 274 | "True" 275 | ] 276 | }, 277 | "execution_count": 10, 278 | "metadata": {}, 279 | "output_type": "execute_result" 280 | } 281 | ], 282 | "source": [ 283 | "myInitiative.delete()" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": null, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [] 292 | } 293 | ], 294 | "metadata": { 295 | "kernelspec": { 296 | "display_name": "Python 3 (ipykernel)", 297 | "language": "python", 298 | "name": "python3" 299 | }, 300 | "language_info": { 301 | "codemirror_mode": { 302 | "name": "ipython", 303 | "version": 3 304 | }, 305 | "file_extension": ".py", 306 | "mimetype": "text/x-python", 307 | "name": "python", 308 | "nbconvert_exporter": "python", 309 | "pygments_lexer": "ipython3", 310 | "version": "3.7.11" 311 | } 312 | }, 313 | "nbformat": 4, 314 | "nbformat_minor": 2 315 | } 316 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Cloning an initiative in another org-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Cloning an Initiative in another org" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Cloning an initiative in a Hub Premium org" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We start by fetching the initiative we would like to clone" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 3, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "" 75 | ] 76 | }, 77 | "execution_count": 3, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "i1 = myHub.initiatives.get('d2f7b4a5e6c74fad91940ee4d0458ff6')\n", 84 | "i1" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": {}, 90 | "source": [ 91 | "We now sign-in to the other org" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 6, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "name": "stdout", 101 | "output_type": "stream", 102 | "text": [ 103 | "Enter password: ········\n" 104 | ] 105 | } 106 | ], 107 | "source": [ 108 | "hub_premium = Hub(\"https://cityx.maps.arcgis.com\", \"cityofx_admin\")" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 9, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "data": { 118 | "text/html": [ 119 | "
\n", 120 | "
\n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | "
\n", 125 | "\n", 126 | "
\n", 127 | " Python initiative - new-copy-1585082304665\n", 128 | " \n", 129 | "
Python initiative - new-copy-1585082304665 Custom initiativeHub Initiative by cityofx_admin\n", 130 | "
Last Modified: March 24, 2020\n", 131 | "
0 comments, 0 views\n", 132 | "
\n", 133 | "
\n", 134 | " " 135 | ], 136 | "text/plain": [ 137 | "" 138 | ] 139 | }, 140 | "execution_count": 9, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "i2 = hub_premium.initiatives.clone(i1, origin_hub=myHub)\n", 147 | "i2.item" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "### Cloning an initiative in a Hub Basic org" 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "We start by signing-in to the org" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 11, 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "name": "stdout", 171 | "output_type": "stream", 172 | "text": [ 173 | "Enter password: ········\n" 174 | ] 175 | } 176 | ], 177 | "source": [ 178 | "hub_basic = Hub(\"https://prod-bas-hub.maps.arcgis.com\", \"prod_bas_hub_admin\")" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 12, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/html": [ 189 | "
\n", 190 | "
\n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | "
\n", 195 | "\n", 196 | "
\n", 197 | " Python initiative - new-copy-1585082640789\n", 198 | " \n", 199 | "
Hub Site Application by prod_bas_hub_admin\n", 200 | "
Last Modified: March 24, 2020\n", 201 | "
0 comments, 0 views\n", 202 | "
\n", 203 | "
\n", 204 | " " 205 | ], 206 | "text/plain": [ 207 | "" 208 | ] 209 | }, 210 | "execution_count": 12, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "site = hub_basic.initiatives.clone(i1, origin_hub=myHub)\n", 217 | "site.item" 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "As we see above, cloning an initiative in a Hub Basic org, returns just the cloned __site__ of that initiative" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [] 233 | } 234 | ], 235 | "metadata": { 236 | "kernelspec": { 237 | "display_name": "Python 3", 238 | "language": "python", 239 | "name": "python3" 240 | }, 241 | "language_info": { 242 | "codemirror_mode": { 243 | "name": "ipython", 244 | "version": 3 245 | }, 246 | "file_extension": ".py", 247 | "mimetype": "text/x-python", 248 | "name": "python", 249 | "nbconvert_exporter": "python", 250 | "pygments_lexer": "ipython3", 251 | "version": "3.7.1" 252 | } 253 | }, 254 | "nbformat": 4, 255 | "nbformat_minor": 2 256 | } 257 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Cloning an initiative in the same org-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Cloning an Initiative in the same org" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Cloning an initiative" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We start by fetching the initiative we would like to clone" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "" 75 | ] 76 | }, 77 | "execution_count": 4, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "i1 = myHub.initiatives.get('d2f7b4a5e6c74fad91940ee4d0458ff6')\n", 84 | "i1" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 5, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/html": [ 95 | "
\n", 96 | "
\n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | "
\n", 101 | "\n", 102 | "
\n", 103 | " Python initiative - Manushi clone\n", 104 | " \n", 105 | "
Python initiative - Manushi clone Custom initiativeHub Initiative by mmajumdar_dcdev\n", 106 | "
Last Modified: March 24, 2020\n", 107 | "
0 comments, 1 views\n", 108 | "
\n", 109 | "
\n", 110 | " " 111 | ], 112 | "text/plain": [ 113 | "" 114 | ] 115 | }, 116 | "execution_count": 5, 117 | "metadata": {}, 118 | "output_type": "execute_result" 119 | } 120 | ], 121 | "source": [ 122 | "i1_clone = myHub.initiatives.clone(i1, title='Python initiative - Manushi clone')\n", 123 | "i1_clone.item" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [] 132 | } 133 | ], 134 | "metadata": { 135 | "kernelspec": { 136 | "display_name": "Python 3", 137 | "language": "python", 138 | "name": "python3" 139 | }, 140 | "language_info": { 141 | "codemirror_mode": { 142 | "name": "ipython", 143 | "version": 3 144 | }, 145 | "file_extension": ".py", 146 | "mimetype": "text/x-python", 147 | "name": "python", 148 | "nbconvert_exporter": "python", 149 | "pygments_lexer": "ipython3", 150 | "version": "3.7.1" 151 | } 152 | }, 153 | "nbformat": 4, 154 | "nbformat_minor": 2 155 | } 156 | -------------------------------------------------------------------------------- /examples/For arcgishub library/.ipynb_checkpoints/Cloning sites from ArcGIS Hub to Enterprise-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Cloning sites from ArcGIS Hub to Enterprise\n", 8 | "\n", 9 | "A Site is container for web addressable content. Sites is a feature supported in both ArcGIS Online (through ArcGIS Hub) and ArcGIS Enterprise. \n", 10 | "\n", 11 | "We will start by exploring Sites as supported in ArcGIS Hub. A site within ArcGIS Hub exists on it's own or could be part of an initiative. " 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 1, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from arcgishub.hub import Hub" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "### Cloning site from Hub Basic to Enterprise" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "hub_basic = Hub(\"https://www.arcgis.com\", \"prod_bas_hub_admin\")" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "data": { 54 | "text/html": [ 55 | "
\n", 56 | "
\n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | "
\n", 61 | "\n", 62 | "
\n", 63 | " New site - Manushi\n", 64 | " \n", 65 | "
Hub Site Application by prod_bas_hub_admin\n", 66 | "
Last Modified: March 24, 2020\n", 67 | "
0 comments, 1 views\n", 68 | "
\n", 69 | "
\n", 70 | " " 71 | ], 72 | "text/plain": [ 73 | "" 74 | ] 75 | }, 76 | "execution_count": 4, 77 | "metadata": {}, 78 | "output_type": "execute_result" 79 | } 80 | ], 81 | "source": [ 82 | "site = hub_basic.sites.get('c4de575b3cb1492a89e7bf9d45ee4520')\n", 83 | "site.item" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 5, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "eHub = Hub(\"url\", \"username\", \"password\")" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 6, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "data": { 102 | "text/html": [ 103 | "
\n", 104 | "
\n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | "
\n", 109 | "\n", 110 | "
\n", 111 | " New site - Manushi-copy-1585093832239\n", 112 | " \n", 113 | "
Site Application by admin\n", 114 | "
Last Modified: March 24, 2020\n", 115 | "
0 comments, 0 views\n", 116 | "
\n", 117 | "
\n", 118 | " " 119 | ], 120 | "text/plain": [ 121 | "" 122 | ] 123 | }, 124 | "execution_count": 6, 125 | "metadata": {}, 126 | "output_type": "execute_result" 127 | } 128 | ], 129 | "source": [ 130 | "site_cloned = eHub.sites.clone(site)\n", 131 | "site_cloned.item" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "### Cloning site from ArcGIS Enterprise to Hub" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 7, 144 | "metadata": {}, 145 | "outputs": [ 146 | { 147 | "data": { 148 | "text/html": [ 149 | "
\n", 150 | "
\n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | "
\n", 155 | "\n", 156 | "
\n", 157 | " Manushi enterprise site new\n", 158 | " \n", 159 | "
Site Application by admin\n", 160 | "
Last Modified: March 24, 2020\n", 161 | "
0 comments, 2 views\n", 162 | "
\n", 163 | "
\n", 164 | " " 165 | ], 166 | "text/plain": [ 167 | "" 168 | ] 169 | }, 170 | "execution_count": 7, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "e_site = eHub.sites.get('9b0c589a8bb041d3af072b0cbbfde8a9')\n", 177 | "e_site.item" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 8, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "data": { 187 | "text/html": [ 188 | "
\n", 189 | "
\n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | "
\n", 194 | "\n", 195 | "
\n", 196 | " Manushi enterprise site new-copy-1585093879512\n", 197 | " \n", 198 | "
Hub Site Application by prod_bas_hub_admin\n", 199 | "
Last Modified: March 24, 2020\n", 200 | "
0 comments, 0 views\n", 201 | "
\n", 202 | "
\n", 203 | " " 204 | ], 205 | "text/plain": [ 206 | "" 207 | ] 208 | }, 209 | "execution_count": 8, 210 | "metadata": {}, 211 | "output_type": "execute_result" 212 | } 213 | ], 214 | "source": [ 215 | "esite_cloned = hub_basic.sites.clone(e_site)\n", 216 | "esite_cloned.item" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [] 225 | } 226 | ], 227 | "metadata": { 228 | "kernelspec": { 229 | "display_name": "Python 3", 230 | "language": "python", 231 | "name": "python3" 232 | }, 233 | "language_info": { 234 | "codemirror_mode": { 235 | "name": "ipython", 236 | "version": 3 237 | }, 238 | "file_extension": ".py", 239 | "mimetype": "text/x-python", 240 | "name": "python", 241 | "nbconvert_exporter": "python", 242 | "pygments_lexer": "ipython3", 243 | "version": "3.7.1" 244 | } 245 | }, 246 | "nbformat": 4, 247 | "nbformat_minor": 2 248 | } 249 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Accessing events and plotting them on a map.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Accessign events in your Hub and plotting them on a map" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "ArcGIS Hub supports engagement through in-person and virtual events.\n", 15 | "\n", 16 | "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.\n", 17 | "\n", 18 | "A Hub has many Events that can be associated with an Initiative." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from arcgishub import hub" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "myhub = hub.Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "### Searching for events\n", 52 | "\n", 53 | "You can search for `events` of a Hub using the following parameters:\n", 54 | "* `initiative_id`\n", 55 | "* `title`\n", 56 | "* `venue`\n", 57 | "* `organizer_name`" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 3, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "[,\n", 69 | " ,\n", 70 | " ,\n", 71 | " ,\n", 72 | " ]" 73 | ] 74 | }, 75 | "execution_count": 3, 76 | "metadata": {}, 77 | "output_type": "execute_result" 78 | } 79 | ], 80 | "source": [ 81 | "all_events = myhub.events.search()\n", 82 | "all_events[:5]" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 4, 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "data": { 92 | "text/plain": [ 93 | "[,\n", 94 | " ,\n", 95 | " ,\n", 96 | " ,\n", 97 | " ,\n", 98 | " ,\n", 99 | " ,\n", 100 | " ,\n", 101 | " ]" 102 | ] 103 | }, 104 | "execution_count": 4, 105 | "metadata": {}, 106 | "output_type": "execute_result" 107 | } 108 | ], 109 | "source": [ 110 | "myhub.events.search(title='Hub')" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 5, 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "data": { 120 | "text/plain": [ 121 | "[,\n", 122 | " ,\n", 123 | " ,\n", 124 | " ,\n", 125 | " ,\n", 126 | " ,\n", 127 | " ,\n", 128 | " ]" 129 | ] 130 | }, 131 | "execution_count": 5, 132 | "metadata": {}, 133 | "output_type": "execute_result" 134 | } 135 | ], 136 | "source": [ 137 | "myhub.events.search(organizer_name='Manushi')" 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "metadata": {}, 143 | "source": [ 144 | "### Fetching an event" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "You can fetch a particular event by passing in the event id to the `get()` method" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 6, 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "data": { 161 | "text/plain": [ 162 | "" 163 | ] 164 | }, 165 | "execution_count": 6, 166 | "metadata": {}, 167 | "output_type": "execute_result" 168 | } 169 | ], 170 | "source": [ 171 | "event1 = myhub.events.get(2)\n", 172 | "event1" 173 | ] 174 | }, 175 | { 176 | "cell_type": "markdown", 177 | "metadata": {}, 178 | "source": [ 179 | "### Accessing properties of an event" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "You can access properties of an event as follows:" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 7, 192 | "metadata": {}, 193 | "outputs": [ 194 | { 195 | "data": { 196 | "text/plain": [ 197 | "1540654200000" 198 | ] 199 | }, 200 | "execution_count": 7, 201 | "metadata": {}, 202 | "output_type": "execute_result" 203 | } 204 | ], 205 | "source": [ 206 | "event1.start_date" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 8, 212 | "metadata": {}, 213 | "outputs": [ 214 | { 215 | "data": { 216 | "text/plain": [ 217 | "'Anacostia Neighborhood Library'" 218 | ] 219 | }, 220 | "execution_count": 8, 221 | "metadata": {}, 222 | "output_type": "execute_result" 223 | } 224 | ], 225 | "source": [ 226 | "event1.venue" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": 9, 232 | "metadata": {}, 233 | "outputs": [ 234 | { 235 | "data": { 236 | "text/plain": [ 237 | "'[{\"name\":\"Justin Prather\",\"contact\":\"j.prather@esri.com\"}]'" 238 | ] 239 | }, 240 | "execution_count": 9, 241 | "metadata": {}, 242 | "output_type": "execute_result" 243 | } 244 | ], 245 | "source": [ 246 | "event1.organizers" 247 | ] 248 | }, 249 | { 250 | "cell_type": "markdown", 251 | "metadata": {}, 252 | "source": [ 253 | "### Visualize all events on a map" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 10, 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "data": { 263 | "application/vnd.jupyter.widget-view+json": { 264 | "model_id": "bdbb1bee693047b0ba907b8f469d091a", 265 | "version_major": 2, 266 | "version_minor": 0 267 | }, 268 | "text/plain": [ 269 | "MapView(layout=Layout(height='400px', width='100%'))" 270 | ] 271 | }, 272 | "metadata": {}, 273 | "output_type": "display_data" 274 | }, 275 | { 276 | "data": { 277 | "text/html": [ 278 | "
" 279 | ], 280 | "text/plain": [ 281 | "" 282 | ] 283 | }, 284 | "metadata": {}, 285 | "output_type": "display_data" 286 | }, 287 | { 288 | "data": { 289 | "text/html": [ 290 | "
" 291 | ], 292 | "text/plain": [ 293 | "" 294 | ] 295 | }, 296 | "metadata": {}, 297 | "output_type": "display_data" 298 | } 299 | ], 300 | "source": [ 301 | "myhub.events.get_map()" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "![event_map](https://user-images.githubusercontent.com/13968196/54644431-a31e2d80-4a6f-11e9-845a-96998ef6b082.PNG)" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [] 317 | } 318 | ], 319 | "metadata": { 320 | "kernelspec": { 321 | "display_name": "Python 3 (ipykernel)", 322 | "language": "python", 323 | "name": "python3" 324 | }, 325 | "language_info": { 326 | "codemirror_mode": { 327 | "name": "ipython", 328 | "version": 3 329 | }, 330 | "file_extension": ".py", 331 | "mimetype": "text/x-python", 332 | "name": "python", 333 | "nbconvert_exporter": "python", 334 | "pygments_lexer": "ipython3", 335 | "version": "3.7.11" 336 | } 337 | }, 338 | "nbformat": 4, 339 | "nbformat_minor": 2 340 | } 341 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Accessing initiatives.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Accessing Initiatives" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Fetching a single initiative\n", 57 | "\n", 58 | "To fetch a particular initiative pass the initiative itemId to the `get` method on `initiatives`" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "walkability_init = myHub.initiatives.get('07fad5be49da45bea02c8f5b0876be24')" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 4, 73 | "metadata": {}, 74 | "outputs": [ 75 | { 76 | "data": { 77 | "text/html": [ 78 | "
\n", 79 | "
\n", 80 | " \n", 81 | " \n", 82 | " \n", 83 | "
\n", 84 | "\n", 85 | "
\n", 86 | " Walkability Assessment \n", 87 | " \n", 88 | "
Assess how walkable your city isHub Initiative by mmajumdar_dcdev\n", 89 | "
Last Modified: June 28, 2019\n", 90 | "
0 comments, 270 views\n", 91 | "
\n", 92 | "
\n", 93 | " " 94 | ], 95 | "text/plain": [ 96 | "" 97 | ] 98 | }, 99 | "execution_count": 4, 100 | "metadata": {}, 101 | "output_type": "execute_result" 102 | } 103 | ], 104 | "source": [ 105 | "walkability_init.item" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "Properties of an initiative can be accessed as follows:" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 5, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "data": { 122 | "text/plain": [ 123 | "'12b8f977ee1e46998c2d8aa39feb15a7'" 124 | ] 125 | }, 126 | "execution_count": 5, 127 | "metadata": {}, 128 | "output_type": "execute_result" 129 | } 130 | ], 131 | "source": [ 132 | "walkability_init.site_id" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "### Searching for initiatives" 140 | ] 141 | }, 142 | { 143 | "cell_type": "markdown", 144 | "metadata": {}, 145 | "source": [ 146 | "You can search for initiatives based on `title`, `owner`, information about when the initiative was `created` and last `modified` or `tags`" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 6, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "[,\n", 158 | " ,\n", 159 | " ,\n", 160 | " ,\n", 161 | " ,\n", 162 | " ,\n", 163 | " ]" 164 | ] 165 | }, 166 | "execution_count": 6, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "myHub.initiatives.search(title='Vision Zero', owner='mmajumdar_dcdev', tags='Hub')" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": {}, 179 | "outputs": [], 180 | "source": [] 181 | } 182 | ], 183 | "metadata": { 184 | "kernelspec": { 185 | "display_name": "Python 3 (ipykernel)", 186 | "language": "python", 187 | "name": "python3" 188 | }, 189 | "language_info": { 190 | "codemirror_mode": { 191 | "name": "ipython", 192 | "version": 3 193 | }, 194 | "file_extension": ".py", 195 | "mimetype": "text/x-python", 196 | "name": "python", 197 | "nbconvert_exporter": "python", 198 | "pygments_lexer": "ipython3", 199 | "version": "3.7.11" 200 | } 201 | }, 202 | "nbformat": 4, 203 | "nbformat_minor": 2 204 | } 205 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Accessing sites.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Accessing and searching Sites\n", 8 | "\n", 9 | "A Site is container for web addressable content. Sites is a feature supported in both ArcGIS Online (through ArcGIS Hub) and ArcGIS Enterprise. \n", 10 | "\n", 11 | "We will start by exploring Sites as supported in ArcGIS Hub. A site within ArcGIS Hub exists on it's own or could be part of an initiative. " 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 1, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "import sys\n", 21 | "sys.path.append(\"../../\")\n", 22 | "from arcgishub.hub import Hub" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 2, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "myhub = Hub()" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "You can also connect to your Enterprise organization similarly to work with the `sites` in your organization." 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "### Fetching a site\n", 46 | "\n", 47 | "You can fetch a particular site by its `itemid`" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "metadata": {}, 54 | "outputs": [ 55 | { 56 | "data": { 57 | "text/html": [ 58 | "
\n", 59 | "
\n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | "
\n", 64 | "\n", 65 | "
\n", 66 | " Coronavirus Response\n", 67 | " \n", 68 | "
Discover the latest resources, maps and information about the coronavirus (COVID-19) outbreak in your community.Hub Site Application by ArcGIS_Hub\n", 69 | "
Last Modified: September 15, 2021\n", 70 | "
0 comments, 64263 views\n", 71 | "
\n", 72 | "
\n", 73 | " " 74 | ], 75 | "text/plain": [ 76 | "" 77 | ] 78 | }, 79 | "execution_count": 3, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | } 83 | ], 84 | "source": [ 85 | "site = myhub.sites.get('cf2e660cd39347eea951c990718fd8a3')\n", 86 | "site.item" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "### Searching for sites" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [ 102 | "sites = myhub.sites.search(title='Manushi', owner='mmajumdar_dcdev')[:3]\n", 103 | "sites" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "### Fetching the site for particular initiative (Hub Premium orgs)" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [ 119 | "initiative1 = myhub.initiatives.get('07fad5be49da45bea02c8f5b0876be24')\n", 120 | "site1_id = initiative1.site_id\n", 121 | "site1_id" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "site1 = myhub.sites.get(site1_id)\n", 131 | "site1" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "metadata": {}, 138 | "outputs": [], 139 | "source": [ 140 | "site1.url" 141 | ] 142 | } 143 | ], 144 | "metadata": { 145 | "kernelspec": { 146 | "display_name": "Python 3 (ipykernel)", 147 | "language": "python", 148 | "name": "python3" 149 | }, 150 | "language_info": { 151 | "codemirror_mode": { 152 | "name": "ipython", 153 | "version": 3 154 | }, 155 | "file_extension": ".py", 156 | "mimetype": "text/x-python", 157 | "name": "python", 158 | "nbconvert_exporter": "python", 159 | "pygments_lexer": "ipython3", 160 | "version": "3.9.6" 161 | } 162 | }, 163 | "nbformat": 4, 164 | "nbformat_minor": 2 165 | } 166 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Adding, updating, deleting events.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Working with Events" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "ArcGIS Hub supports engagement through in-person and virtual events.\n", 15 | "\n", 16 | "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.\n", 17 | "\n", 18 | "A Hub has many Events that can be associated with an Initiative." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "import sys\n", 28 | "sys.path.append(\"../../\")\n", 29 | "\n", 30 | "from arcgishub import hub" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 2, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "myhub = hub.Hub(\"https://www.arcgis.com\", 'aturner')" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": {}, 45 | "source": [ 46 | "### Searching for events\n", 47 | "\n", 48 | "You can search for `events` of a Hub using the following parameters:\n", 49 | "* `initiative_id`\n", 50 | "* `title`\n", 51 | "* `venue`\n", 52 | "* `organizer_name`" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 3, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "name": "stdout", 62 | "output_type": "stream", 63 | "text": [ 64 | "_hub_environment: https://dc.mapsqa.arcgis.com\n" 65 | ] 66 | }, 67 | { 68 | "ename": "Exception", 69 | "evalue": "{'code': 400, 'message': 'No events service found. Events may not be enabled or you lack permissions for this organization.'}", 70 | "output_type": "error", 71 | "traceback": [ 72 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 73 | "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", 74 | "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m all_events \u001b[39m=\u001b[39m myhub\u001b[39m.\u001b[39;49mevents\u001b[39m.\u001b[39;49msearch()\n\u001b[1;32m 2\u001b[0m all_events[:\u001b[39m5\u001b[39m]\n", 75 | "File \u001b[0;32m~/Projects/esri/hub-py/examples/For arcgishub library/../../arcgishub/events.py:397\u001b[0m, in \u001b[0;36mEventManager.search\u001b[0;34m(self, initiative_id, title, venue, organizer_name)\u001b[0m\n\u001b[1;32m 377\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\" \u001b[39;00m\n\u001b[1;32m 378\u001b[0m \u001b[39mSearches for events within a Hub.\u001b[39;00m\n\u001b[1;32m 379\u001b[0m \u001b[39m\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 394\u001b[0m \u001b[39m\u001b[39;00m\n\u001b[1;32m 395\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 396\u001b[0m events \u001b[39m=\u001b[39m []\n\u001b[0;32m--> 397\u001b[0m events \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_all_events()\n\u001b[1;32m 398\u001b[0m \u001b[39mif\u001b[39;00m initiative_id\u001b[39m!=\u001b[39m\u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 399\u001b[0m \u001b[39m#events = \u001b[39;00m\n\u001b[1;32m 400\u001b[0m events \u001b[39m=\u001b[39m [event \u001b[39mfor\u001b[39;00m event \u001b[39min\u001b[39;00m events \u001b[39mif\u001b[39;00m initiative_id\u001b[39m==\u001b[39mevent\u001b[39m.\u001b[39minitiative_id]\n", 76 | "File \u001b[0;32m~/Projects/esri/hub-py/examples/For arcgishub library/../../arcgishub/events.py:230\u001b[0m, in \u001b[0;36mEventManager._all_events\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 223\u001b[0m url \u001b[39m=\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mhttps://\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_hub\u001b[39m.\u001b[39m_hub_environment\u001b[39m}\u001b[39;00m\u001b[39m/api/v3/events/\u001b[39m\u001b[39m'\u001b[39m\u001b[39m+self._hub.enterprise_org_id+\u001b[39m\u001b[39m'\u001b[39m\u001b[39m/Hub Events/FeatureServer/0/query\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 224\u001b[0m params \u001b[39m=\u001b[39m {\n\u001b[1;32m 225\u001b[0m \u001b[39m'\u001b[39m\u001b[39mf\u001b[39m\u001b[39m'\u001b[39m :\u001b[39m'\u001b[39m\u001b[39mjson\u001b[39m\u001b[39m'\u001b[39m, \n\u001b[1;32m 226\u001b[0m \u001b[39m'\u001b[39m\u001b[39moutFields\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m'\u001b[39m\u001b[39m*\u001b[39m\u001b[39m'\u001b[39m, \n\u001b[1;32m 227\u001b[0m \u001b[39m'\u001b[39m\u001b[39mwhere\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m'\u001b[39m\u001b[39m1=1\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[1;32m 228\u001b[0m \u001b[39m'\u001b[39m\u001b[39mtoken\u001b[39m\u001b[39m'\u001b[39m: \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_gis\u001b[39m.\u001b[39m_con\u001b[39m.\u001b[39mtoken\n\u001b[1;32m 229\u001b[0m }\n\u001b[0;32m--> 230\u001b[0m all_events \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_gis\u001b[39m.\u001b[39;49m_con\u001b[39m.\u001b[39;49mget(url, params)\n\u001b[1;32m 231\u001b[0m _events_data \u001b[39m=\u001b[39m all_events[\u001b[39m'\u001b[39m\u001b[39mfeatures\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[1;32m 232\u001b[0m \u001b[39mfor\u001b[39;00m event \u001b[39min\u001b[39;00m _events_data:\n", 77 | "File \u001b[0;32m~/Library/Python/3.9/lib/python/site-packages/arcgis/gis/_impl/_con/_connection.py:884\u001b[0m, in \u001b[0;36mConnection.get\u001b[0;34m(self, path, params, **kwargs)\u001b[0m\n\u001b[1;32m 882\u001b[0m \u001b[39mif\u001b[39;00m return_raw_response:\n\u001b[1;32m 883\u001b[0m \u001b[39mreturn\u001b[39;00m resp\n\u001b[0;32m--> 884\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_handle_response(\n\u001b[1;32m 885\u001b[0m resp,\n\u001b[1;32m 886\u001b[0m file_name,\n\u001b[1;32m 887\u001b[0m out_path,\n\u001b[1;32m 888\u001b[0m try_json,\n\u001b[1;32m 889\u001b[0m force_bytes\u001b[39m=\u001b[39;49mkwargs\u001b[39m.\u001b[39;49mpop(\u001b[39m\"\u001b[39;49m\u001b[39mforce_bytes\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mFalse\u001b[39;49;00m),\n\u001b[1;32m 890\u001b[0m ignore_error_key\u001b[39m=\u001b[39;49mignore_error_key,\n\u001b[1;32m 891\u001b[0m )\n", 78 | "File \u001b[0;32m~/Library/Python/3.9/lib/python/site-packages/arcgis/gis/_impl/_con/_connection.py:1007\u001b[0m, in \u001b[0;36mConnection._handle_response\u001b[0;34m(self, resp, file_name, out_path, try_json, force_bytes, ignore_error_key)\u001b[0m\n\u001b[1;32m 1005\u001b[0m data \u001b[39m=\u001b[39m json\u001b[39m.\u001b[39mloads(data)\n\u001b[1;32m 1006\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39merror\u001b[39m\u001b[39m\"\u001b[39m \u001b[39min\u001b[39;00m data \u001b[39mand\u001b[39;00m ignore_error_key \u001b[39m==\u001b[39m \u001b[39mFalse\u001b[39;00m:\n\u001b[0;32m-> 1007\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mException\u001b[39;00m(data[\u001b[39m\"\u001b[39m\u001b[39merror\u001b[39m\u001b[39m\"\u001b[39m])\n\u001b[1;32m 1008\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 1009\u001b[0m \u001b[39mtry\u001b[39;00m:\n", 79 | "\u001b[0;31mException\u001b[0m: {'code': 400, 'message': 'No events service found. Events may not be enabled or you lack permissions for this organization.'}" 80 | ] 81 | } 82 | ], 83 | "source": [ 84 | "all_events = myhub.events.search()\n", 85 | "all_events[:5]" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "### Adding a new event" 93 | ] 94 | }, 95 | { 96 | "cell_type": "markdown", 97 | "metadata": {}, 98 | "source": [ 99 | "You can add a new event by passing the necessary attributes as `event_properties` to the `add()` method.\n", 100 | "\n", 101 | "The required attributes needed for adding an event are:\n", 102 | "* `title`\n", 103 | "* `description`\n", 104 | "* `initiativeId`\n", 105 | "* `venue`\n", 106 | "* `address1`\n", 107 | "* `status`\n", 108 | "* `startDate`\n", 109 | "* `endDate`\n", 110 | "* `isAllDay`\n", 111 | "\n", 112 | "The other optional attributes that can also be provided while creating an event are:\n", 113 | "* `url` if web event\n", 114 | "* `attendance` capacity of the event\n", 115 | "* `status` - public/planned/private\n", 116 | "* `organizers` - dictionary with values for `name`, `contact` (email), `username` (ArcGIS Online username)\n", 117 | "* `sponsors` - - dictionary with values for `name`, `contact` (email/website/Twitter/etc), `username` (ArcGIS Online username)\n", 118 | "* `geometry` - In the absence of this field, the `address1` field is geocoded\n", 119 | "\n", 120 | "Follow through the example below to see how to create an event." 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": {}, 127 | "outputs": [], 128 | "source": [ 129 | "event_properties = {\n", 130 | " \"title\":\"Updated event in python\",\n", 131 | " 'description': 'New event in 2022',\n", 132 | " 'initiativeId': 'b4cbdaf65f3c4b55a8fb1f8dcbe0fc3b',\n", 133 | " 'venue': 'ESRI R&D Center',\n", 134 | " 'address1': '1001 19th St N #910, Arlington, VA 22209',\n", 135 | " 'status': 'public',\n", 136 | " 'startDate': 1585356198,\n", 137 | " 'endDate': 1585399398,\n", 138 | " 'isAllDay': 0,\n", 139 | " 'geometry': {'x': -77.06915099999999, 'y': 38.89740599999999}\n", 140 | "}" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "metadata": {}, 147 | "outputs": [], 148 | "source": [ 149 | "new_event = myhub.events.add(event_properties)\n", 150 | "new_event" 151 | ] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": {}, 156 | "source": [ 157 | "### Update an event" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "In order to update an event, pass the particular attributes that need updating to the `event_properties` parameter" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": null, 170 | "metadata": {}, 171 | "outputs": [], 172 | "source": [ 173 | "new_event.update(event_properties={'status':'private'})" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "new_event.access" 183 | ] 184 | }, 185 | { 186 | "cell_type": "markdown", 187 | "metadata": {}, 188 | "source": [ 189 | "### Delete an event" 190 | ] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": null, 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [ 198 | "myhub.events.get(1124).delete()" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "metadata": {}, 205 | "outputs": [], 206 | "source": [ 207 | "new_event.delete()" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [] 216 | } 217 | ], 218 | "metadata": { 219 | "kernelspec": { 220 | "display_name": "Python 3 (ipykernel)", 221 | "language": "python", 222 | "name": "python3" 223 | }, 224 | "language_info": { 225 | "codemirror_mode": { 226 | "name": "ipython", 227 | "version": 3 228 | }, 229 | "file_extension": ".py", 230 | "mimetype": "text/x-python", 231 | "name": "python", 232 | "nbconvert_exporter": "python", 233 | "pygments_lexer": "ipython3", 234 | "version": "3.9.6" 235 | } 236 | }, 237 | "nbformat": 4, 238 | "nbformat_minor": 2 239 | } 240 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Adding, updating, deleting initiatives.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Adding, updating and deleting Initiatives" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Adding new initiaitve" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "To add a new initiative to your hub, all you do is call the `add` method with the `title` and `description` (optional) for the initiative.\n", 64 | "\n", 65 | "Collaboration and Open Data groups corresponding to the initiative are created as part of the process on initiative creation." 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 3, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "myInitiative = myHub.initiatives.add(title='Python initiative 2022')" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 4, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "data": { 84 | "text/html": [ 85 | "
\n", 86 | "
\n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | "
\n", 91 | "\n", 92 | "
\n", 93 | " Python initiative 2022\n", 94 | " \n", 95 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by mmajumdar_dcdev\n", 96 | "
Last Modified: October 27, 2022\n", 97 | "
0 comments, 0 views\n", 98 | "
\n", 99 | "
\n", 100 | " " 101 | ], 102 | "text/plain": [ 103 | "" 104 | ] 105 | }, 106 | "execution_count": 4, 107 | "metadata": {}, 108 | "output_type": "execute_result" 109 | } 110 | ], 111 | "source": [ 112 | "myInitiative.item" 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "### Updating initiative" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "`description` and `snippet` of an initiative can be updated directly as shown below" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 5, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "myInitiative.snippet = 'Create your own initiative by combining existing applications with a custom site'" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 6, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/html": [ 146 | "
\n", 147 | "
\n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | "
\n", 152 | "\n", 153 | "
\n", 154 | " Python initiative 2022\n", 155 | " \n", 156 | "
Create your own initiative by combining existing applications with a custom siteHub Initiative by mmajumdar_dcdev\n", 157 | "
Last Modified: October 27, 2022\n", 158 | "
0 comments, 0 views\n", 159 | "
\n", 160 | "
\n", 161 | " " 162 | ], 163 | "text/plain": [ 164 | "" 165 | ] 166 | }, 167 | "execution_count": 6, 168 | "metadata": {}, 169 | "output_type": "execute_result" 170 | } 171 | ], 172 | "source": [ 173 | "#Verify\n", 174 | "myInitiative.item" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 7, 180 | "metadata": {}, 181 | "outputs": [ 182 | { 183 | "data": { 184 | "text/plain": [ 185 | "[]" 186 | ] 187 | }, 188 | "execution_count": 7, 189 | "metadata": {}, 190 | "output_type": "execute_result" 191 | } 192 | ], 193 | "source": [ 194 | "myInitiative.tags" 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "To update other properties of an initiative, you can call the `update` method on the particular initiative that accepts initiative properties to be updated as a dictionary" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": 8, 207 | "metadata": {}, 208 | "outputs": [ 209 | { 210 | "data": { 211 | "text/plain": [ 212 | "True" 213 | ] 214 | }, 215 | "execution_count": 8, 216 | "metadata": {}, 217 | "output_type": "execute_result" 218 | } 219 | ], 220 | "source": [ 221 | "myInitiative.update(initiative_properties={'tags': 'Hub, OpenData'})" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 9, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "['Hub', 'OpenData']" 233 | ] 234 | }, 235 | "execution_count": 9, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "#Verify\n", 242 | "myInitiative.tags" 243 | ] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "metadata": {}, 248 | "source": [ 249 | "Refer the [item properties table](https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#arcgis.gis.Item.update) to learn more about `initiative_properties` that can be updated using this function" 250 | ] 251 | }, 252 | { 253 | "cell_type": "markdown", 254 | "metadata": {}, 255 | "source": [ 256 | "### Delete initiative" 257 | ] 258 | }, 259 | { 260 | "cell_type": "markdown", 261 | "metadata": {}, 262 | "source": [ 263 | "To delete an initiative call the `delete` method on the particular initiative" 264 | ] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": 10, 269 | "metadata": {}, 270 | "outputs": [ 271 | { 272 | "data": { 273 | "text/plain": [ 274 | "True" 275 | ] 276 | }, 277 | "execution_count": 10, 278 | "metadata": {}, 279 | "output_type": "execute_result" 280 | } 281 | ], 282 | "source": [ 283 | "myInitiative.delete()" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": null, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [] 292 | } 293 | ], 294 | "metadata": { 295 | "kernelspec": { 296 | "display_name": "Python 3 (ipykernel)", 297 | "language": "python", 298 | "name": "python3" 299 | }, 300 | "language_info": { 301 | "codemirror_mode": { 302 | "name": "ipython", 303 | "version": 3 304 | }, 305 | "file_extension": ".py", 306 | "mimetype": "text/x-python", 307 | "name": "python", 308 | "nbconvert_exporter": "python", 309 | "pygments_lexer": "ipython3", 310 | "version": "3.7.11" 311 | } 312 | }, 313 | "nbformat": 4, 314 | "nbformat_minor": 2 315 | } 316 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Cloning an initiative in another org.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Cloning an Initiative in another org" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub()" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Cloning an initiative in a Hub Premium org" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We start by fetching the initiative we would like to clone" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 3, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "" 75 | ] 76 | }, 77 | "execution_count": 3, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "i1 = myHub.initiatives.get('d2f7b4a5e6c74fad91940ee4d0458ff6')\n", 84 | "i1" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": {}, 90 | "source": [ 91 | "We now sign-in to the other org" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 6, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "name": "stdout", 101 | "output_type": "stream", 102 | "text": [ 103 | "Enter password: ········\n" 104 | ] 105 | } 106 | ], 107 | "source": [ 108 | "hub_premium = Hub(\"https://cityx.maps.arcgis.com\", \"cityofx_admin\")" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 9, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "data": { 118 | "text/html": [ 119 | "
\n", 120 | "
\n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | "
\n", 125 | "\n", 126 | "
\n", 127 | " Python initiative - new-copy-1585082304665\n", 128 | " \n", 129 | "
Python initiative - new-copy-1585082304665 Custom initiativeHub Initiative by cityofx_admin\n", 130 | "
Last Modified: March 24, 2020\n", 131 | "
0 comments, 0 views\n", 132 | "
\n", 133 | "
\n", 134 | " " 135 | ], 136 | "text/plain": [ 137 | "" 138 | ] 139 | }, 140 | "execution_count": 9, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "i2 = hub_premium.initiatives.clone(i1, origin_hub=myHub)\n", 147 | "i2.item" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "### Cloning an initiative in a Hub Basic org" 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "We start by signing-in to the org" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 11, 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "name": "stdout", 171 | "output_type": "stream", 172 | "text": [ 173 | "Enter password: ········\n" 174 | ] 175 | } 176 | ], 177 | "source": [ 178 | "hub_basic = Hub(\"https://prod-bas-hub.maps.arcgis.com\", \"prod_bas_hub_admin\")" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 12, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/html": [ 189 | "
\n", 190 | "
\n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | "
\n", 195 | "\n", 196 | "
\n", 197 | " Python initiative - new-copy-1585082640789\n", 198 | " \n", 199 | "
Hub Site Application by prod_bas_hub_admin\n", 200 | "
Last Modified: March 24, 2020\n", 201 | "
0 comments, 0 views\n", 202 | "
\n", 203 | "
\n", 204 | " " 205 | ], 206 | "text/plain": [ 207 | "" 208 | ] 209 | }, 210 | "execution_count": 12, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "site = hub_basic.initiatives.clone(i1, origin_hub=myHub)\n", 217 | "site.item" 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "As we see above, cloning an initiative in a Hub Basic org, returns just the cloned __site__ of that initiative" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [] 233 | } 234 | ], 235 | "metadata": { 236 | "kernelspec": { 237 | "display_name": "Python 3", 238 | "language": "python", 239 | "name": "python3" 240 | }, 241 | "language_info": { 242 | "codemirror_mode": { 243 | "name": "ipython", 244 | "version": 3 245 | }, 246 | "file_extension": ".py", 247 | "mimetype": "text/x-python", 248 | "name": "python", 249 | "nbconvert_exporter": "python", 250 | "pygments_lexer": "ipython3", 251 | "version": "3.7.1" 252 | } 253 | }, 254 | "nbformat": 4, 255 | "nbformat_minor": 2 256 | } 257 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Cloning an initiative in the same org.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "### Cloning an Initiative in the same org" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration. Initiatives manage the team, events, content, and experiences around a shared goal.\n", 15 | "\n", 16 | "Initiative configurations can be created individually within a Hub, or they can be made into a Template which is a reusable pattern within or across Hubs. Click [here](https://doc.arcgis.com/en/hub/initiatives/initiatives-overview.htm) to learn more about initiatives." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "from arcgishub.hub import Hub" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "You start by connecting to your GIS and accessing your Hub" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Enter password: ········\n" 45 | ] 46 | } 47 | ], 48 | "source": [ 49 | "myHub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "### Cloning an initiative" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We start by fetching the initiative we would like to clone" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "" 75 | ] 76 | }, 77 | "execution_count": 4, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "i1 = myHub.initiatives.get('d2f7b4a5e6c74fad91940ee4d0458ff6')\n", 84 | "i1" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 5, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/html": [ 95 | "
\n", 96 | "
\n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | "
\n", 101 | "\n", 102 | "
\n", 103 | " Python initiative - Manushi clone\n", 104 | " \n", 105 | "
Python initiative - Manushi clone Custom initiativeHub Initiative by mmajumdar_dcdev\n", 106 | "
Last Modified: March 24, 2020\n", 107 | "
0 comments, 1 views\n", 108 | "
\n", 109 | "
\n", 110 | " " 111 | ], 112 | "text/plain": [ 113 | "" 114 | ] 115 | }, 116 | "execution_count": 5, 117 | "metadata": {}, 118 | "output_type": "execute_result" 119 | } 120 | ], 121 | "source": [ 122 | "i1_clone = myHub.initiatives.clone(i1, title='Python initiative - Manushi clone')\n", 123 | "i1_clone.item" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [] 132 | } 133 | ], 134 | "metadata": { 135 | "kernelspec": { 136 | "display_name": "Python 3", 137 | "language": "python", 138 | "name": "python3" 139 | }, 140 | "language_info": { 141 | "codemirror_mode": { 142 | "name": "ipython", 143 | "version": 3 144 | }, 145 | "file_extension": ".py", 146 | "mimetype": "text/x-python", 147 | "name": "python", 148 | "nbconvert_exporter": "python", 149 | "pygments_lexer": "ipython3", 150 | "version": "3.7.1" 151 | } 152 | }, 153 | "nbformat": 4, 154 | "nbformat_minor": 2 155 | } 156 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Cloning sites from ArcGIS Hub to Enterprise.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Cloning sites from ArcGIS Hub to Enterprise\n", 8 | "\n", 9 | "A Site is container for web addressable content. Sites is a feature supported in both ArcGIS Online (through ArcGIS Hub) and ArcGIS Enterprise. \n", 10 | "\n", 11 | "We will start by exploring Sites as supported in ArcGIS Hub. A site within ArcGIS Hub exists on it's own or could be part of an initiative. " 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 1, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from arcgishub.hub import Hub" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "### Cloning site from Hub Basic to Enterprise" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter password: ········\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "hub_basic = Hub(\"https://www.arcgis.com\", \"prod_bas_hub_admin\")" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "data": { 54 | "text/html": [ 55 | "
\n", 56 | "
\n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | "
\n", 61 | "\n", 62 | "
\n", 63 | " New site - Manushi\n", 64 | " \n", 65 | "
Hub Site Application by prod_bas_hub_admin\n", 66 | "
Last Modified: March 24, 2020\n", 67 | "
0 comments, 1 views\n", 68 | "
\n", 69 | "
\n", 70 | " " 71 | ], 72 | "text/plain": [ 73 | "" 74 | ] 75 | }, 76 | "execution_count": 4, 77 | "metadata": {}, 78 | "output_type": "execute_result" 79 | } 80 | ], 81 | "source": [ 82 | "site = hub_basic.sites.get('c4de575b3cb1492a89e7bf9d45ee4520')\n", 83 | "site.item" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 5, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "eHub = Hub(\"url\", \"username\", \"password\")" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 6, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "data": { 102 | "text/html": [ 103 | "
\n", 104 | "
\n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | "
\n", 109 | "\n", 110 | "
\n", 111 | " New site - Manushi-copy-1585093832239\n", 112 | " \n", 113 | "
Site Application by admin\n", 114 | "
Last Modified: March 24, 2020\n", 115 | "
0 comments, 0 views\n", 116 | "
\n", 117 | "
\n", 118 | " " 119 | ], 120 | "text/plain": [ 121 | "" 122 | ] 123 | }, 124 | "execution_count": 6, 125 | "metadata": {}, 126 | "output_type": "execute_result" 127 | } 128 | ], 129 | "source": [ 130 | "site_cloned = eHub.sites.clone(site)\n", 131 | "site_cloned.item" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "### Cloning site from ArcGIS Enterprise to Hub" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 7, 144 | "metadata": {}, 145 | "outputs": [ 146 | { 147 | "data": { 148 | "text/html": [ 149 | "
\n", 150 | "
\n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | "
\n", 155 | "\n", 156 | "
\n", 157 | " Manushi enterprise site new\n", 158 | " \n", 159 | "
Site Application by admin\n", 160 | "
Last Modified: March 24, 2020\n", 161 | "
0 comments, 2 views\n", 162 | "
\n", 163 | "
\n", 164 | " " 165 | ], 166 | "text/plain": [ 167 | "" 168 | ] 169 | }, 170 | "execution_count": 7, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "e_site = eHub.sites.get('9b0c589a8bb041d3af072b0cbbfde8a9')\n", 177 | "e_site.item" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 8, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "data": { 187 | "text/html": [ 188 | "
\n", 189 | "
\n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | "
\n", 194 | "\n", 195 | "
\n", 196 | " Manushi enterprise site new-copy-1585093879512\n", 197 | " \n", 198 | "
Hub Site Application by prod_bas_hub_admin\n", 199 | "
Last Modified: March 24, 2020\n", 200 | "
0 comments, 0 views\n", 201 | "
\n", 202 | "
\n", 203 | " " 204 | ], 205 | "text/plain": [ 206 | "" 207 | ] 208 | }, 209 | "execution_count": 8, 210 | "metadata": {}, 211 | "output_type": "execute_result" 212 | } 213 | ], 214 | "source": [ 215 | "esite_cloned = hub_basic.sites.clone(e_site)\n", 216 | "esite_cloned.item" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [] 225 | } 226 | ], 227 | "metadata": { 228 | "kernelspec": { 229 | "display_name": "Python 3", 230 | "language": "python", 231 | "name": "python3" 232 | }, 233 | "language_info": { 234 | "codemirror_mode": { 235 | "name": "ipython", 236 | "version": 3 237 | }, 238 | "file_extension": ".py", 239 | "mimetype": "text/x-python", 240 | "name": "python", 241 | "nbconvert_exporter": "python", 242 | "pygments_lexer": "ipython3", 243 | "version": "3.7.1" 244 | } 245 | }, 246 | "nbformat": 4, 247 | "nbformat_minor": 2 248 | } 249 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Reassign initiative to another user.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Changing ownership of initiative\n", 8 | "\n", 9 | "This guide demonstrates the process of reassigning an initiative (or site for Hub Basic or Enterprise) to another user. This script not only changes the ownership of the initiative and site items, but also the associated teams and other items that are included in the initiative's content library.\n", 10 | "\n", 11 | "Note: Only a user with the `administrator` role of the ArcGIS Online organization that contains the initiative can perform this action." 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 1, 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "name": "stdout", 21 | "output_type": "stream", 22 | "text": [ 23 | "Enter password: ········\n" 24 | ] 25 | } 26 | ], 27 | "source": [ 28 | "from arcgishub.hub import Hub\n", 29 | "myhub = Hub(\"https://www.arcgis.com\", \"mmajumdar_dcdev\")" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "metadata": {}, 36 | "outputs": [ 37 | { 38 | "data": { 39 | "text/html": [ 40 | "
\n", 41 | "
\n", 42 | " \n", 43 | " \n", 44 | " \n", 45 | "
\n", 46 | "\n", 47 | "
\n", 48 | " i-with-app\n", 49 | " \n", 50 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by mmajumdar_dcdev\n", 51 | "
Last Modified: July 19, 2021\n", 52 | "
0 comments, 2 views\n", 53 | "
\n", 54 | "
\n", 55 | " " 56 | ], 57 | "text/plain": [ 58 | "" 59 | ] 60 | }, 61 | "execution_count": 2, 62 | "metadata": {}, 63 | "output_type": "execute_result" 64 | } 65 | ], 66 | "source": [ 67 | "i2 = myhub.initiatives.get('2b6e5862bac042559d3845a45f729547')\n", 68 | "i2.item" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 3, 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "data": { 78 | "text/html": [ 79 | "
\n", 80 | "
\n", 81 | " \n", 82 | " \n", 83 | " \n", 84 | "
\n", 85 | "\n", 86 | "
\n", 87 | " i-with-app\n", 88 | " \n", 89 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by manushi.majumdar\n", 90 | "
Last Modified: July 19, 2021\n", 91 | "
0 comments, 3 views\n", 92 | "
\n", 93 | "
\n", 94 | " " 95 | ], 96 | "text/plain": [ 97 | "" 98 | ] 99 | }, 100 | "execution_count": 3, 101 | "metadata": {}, 102 | "output_type": "execute_result" 103 | } 104 | ], 105 | "source": [ 106 | "i2.reassign_to('manushi.majumdar')" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": null, 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [] 115 | } 116 | ], 117 | "metadata": { 118 | "kernelspec": { 119 | "display_name": "Python 3", 120 | "language": "python", 121 | "name": "python3" 122 | }, 123 | "language_info": { 124 | "codemirror_mode": { 125 | "name": "ipython", 126 | "version": 3 127 | }, 128 | "file_extension": ".py", 129 | "mimetype": "text/x-python", 130 | "name": "python", 131 | "nbconvert_exporter": "python", 132 | "pygments_lexer": "ipython3", 133 | "version": "3.7.1" 134 | } 135 | }, 136 | "nbformat": 4, 137 | "nbformat_minor": 2 138 | } 139 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Sharing and unsharing initiatives.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Enter password: ········\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "from arcgishub.hub import Hub\n", 18 | "myhub = Hub(\"https://www.arcgis.com\", 'mmajumdar_dcdev')" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "We start by fetching the initiative we would like to share." 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "data": { 35 | "text/html": [ 36 | "
\n", 37 | "
\n", 38 | " \n", 39 | " \n", 40 | " \n", 41 | "
\n", 42 | "\n", 43 | "
\n", 44 | " sharing-change\n", 45 | " \n", 46 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by mmajumdar_dcdev\n", 47 | "
Last Modified: September 02, 2021\n", 48 | "
0 comments, 11 views\n", 49 | "
\n", 50 | "
\n", 51 | " " 52 | ], 53 | "text/plain": [ 54 | "" 55 | ] 56 | }, 57 | "execution_count": 2, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "i = myhub.initiatives.get('ac12b67e21184a319f1f7abb71ef4625')\n", 64 | "i.item" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "We can share the initiative and its associated site with an organization, publicly, or with specific groups. For more information on the parameters of this method, refer to the API reference [here](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.share)." 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "### Share initiative with org and group at once" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 3, 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "name": "stdout", 88 | "output_type": "stream", 89 | "text": [ 90 | "{'results': [{'itemId': 'b389a831d0514113bb4291f1db8f06c5', 'success': True, 'notSharedWith': ['']}]}\n" 91 | ] 92 | }, 93 | { 94 | "data": { 95 | "text/plain": [ 96 | "{'results': [{'itemId': 'ac12b67e21184a319f1f7abb71ef4625',\n", 97 | " 'success': True,\n", 98 | " 'notSharedWith': ['']}]}" 99 | ] 100 | }, 101 | "execution_count": 3, 102 | "metadata": {}, 103 | "output_type": "execute_result" 104 | } 105 | ], 106 | "source": [ 107 | "i.share(org=True, groups=['ba8edcc4500b4b04966f95c6f76a4e39'])" 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "As we see above, the site and initiative have been successfully shared with the organization and specified group.\n", 115 | "\n", 116 | "### Share initiative publicly" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 4, 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "name": "stdout", 126 | "output_type": "stream", 127 | "text": [ 128 | "{'results': [{'itemId': 'b389a831d0514113bb4291f1db8f06c5', 'success': True, 'notSharedWith': []}]}\n" 129 | ] 130 | }, 131 | { 132 | "data": { 133 | "text/plain": [ 134 | "{'results': [{'itemId': 'ac12b67e21184a319f1f7abb71ef4625',\n", 135 | " 'success': True,\n", 136 | " 'notSharedWith': []}]}" 137 | ] 138 | }, 139 | "execution_count": 4, 140 | "metadata": {}, 141 | "output_type": "execute_result" 142 | } 143 | ], 144 | "source": [ 145 | "i.share(everyone=True)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "### Share initiative privately\n", 153 | "\n", 154 | "In order to share an initiative privately (neither organization, nor public access), you execute the `share()` method without parameters as shown below." 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 5, 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "{'results': [{'itemId': 'b389a831d0514113bb4291f1db8f06c5', 'success': True, 'notSharedWith': []}]}\n" 167 | ] 168 | }, 169 | { 170 | "data": { 171 | "text/plain": [ 172 | "{'results': [{'itemId': 'ac12b67e21184a319f1f7abb71ef4625',\n", 173 | " 'success': True,\n", 174 | " 'notSharedWith': []}]}" 175 | ] 176 | }, 177 | "execution_count": 5, 178 | "metadata": {}, 179 | "output_type": "execute_result" 180 | } 181 | ], 182 | "source": [ 183 | "i.share()" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "### Unshare initiatives with group\n", 191 | "\n", 192 | "You can also disable sharing of an initiative (and its site) with a group or list of groups as shown below." 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 6, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "name": "stdout", 202 | "output_type": "stream", 203 | "text": [ 204 | "{'notUnsharedFrom': [''], 'itemId': 'b389a831d0514113bb4291f1db8f06c5'}\n" 205 | ] 206 | }, 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "{'notUnsharedFrom': [''], 'itemId': 'ac12b67e21184a319f1f7abb71ef4625'}" 211 | ] 212 | }, 213 | "execution_count": 6, 214 | "metadata": {}, 215 | "output_type": "execute_result" 216 | } 217 | ], 218 | "source": [ 219 | "i.unshare(groups=['ba8edcc4500b4b04966f95c6f76a4e39'])" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": null, 225 | "metadata": {}, 226 | "outputs": [], 227 | "source": [] 228 | } 229 | ], 230 | "metadata": { 231 | "kernelspec": { 232 | "display_name": "Python 3", 233 | "language": "python", 234 | "name": "python3" 235 | }, 236 | "language_info": { 237 | "codemirror_mode": { 238 | "name": "ipython", 239 | "version": 3 240 | }, 241 | "file_extension": ".py", 242 | "mimetype": "text/x-python", 243 | "name": "python", 244 | "nbconvert_exporter": "python", 245 | "pygments_lexer": "ipython3", 246 | "version": "3.7.1" 247 | } 248 | }, 249 | "nbformat": 4, 250 | "nbformat_minor": 2 251 | } 252 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Site Theme Editing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "2389e062", 6 | "metadata": {}, 7 | "source": [ 8 | "### Updating the theme of a site\n", 9 | "\n", 10 | "Editing the layout of a site allows us to add, update, delete the sections, rows, cards of the site and customize the aesthetics of the site.\n", 11 | "\n", 12 | "Here we see an example to update the theme for a site. While it follows a similar developer experience, it differs in the properties and methods of the site object that are invoked. " 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 1, 18 | "id": "b4d9f581", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "from arcgishub.hub import Hub" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 2, 28 | "id": "b6d10e47", 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "name": "stdout", 33 | "output_type": "stream", 34 | "text": [ 35 | "Enter password: ········\n" 36 | ] 37 | } 38 | ], 39 | "source": [ 40 | "myhub = Hub(\"https://www.arcgis.com\", \"mmajumdar_dcdev\")" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 3, 46 | "id": "cb56c8b7", 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/html": [ 52 | "
\n", 53 | "
\n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | "
\n", 58 | "\n", 59 | "
\n", 60 | " site theme update\n", 61 | " \n", 62 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Initiative by mmajumdar_dcdev\n", 63 | "
Last Modified: July 01, 2022\n", 64 | "
0 comments, 1 views\n", 65 | "
\n", 66 | "
\n", 67 | " " 68 | ], 69 | "text/plain": [ 70 | "" 71 | ] 72 | }, 73 | "execution_count": 3, 74 | "metadata": {}, 75 | "output_type": "execute_result" 76 | } 77 | ], 78 | "source": [ 79 | "i1 = myhub.initiatives.get('250c204b00b8440abbe0985c3630604e')\n", 80 | "i1.item" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 4, 86 | "id": "592064f3", 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/html": [ 92 | "
\n", 93 | "
\n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | "
\n", 98 | "\n", 99 | "
\n", 100 | " site theme update\n", 101 | " \n", 102 | "
Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.Hub Site Application by mmajumdar_dcdev\n", 103 | "
Last Modified: July 01, 2022\n", 104 | "
0 comments, 5 views\n", 105 | "
\n", 106 | "
\n", 107 | " " 108 | ], 109 | "text/plain": [ 110 | "" 111 | ] 112 | }, 113 | "execution_count": 4, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "s1 = myhub.sites.get(i1.site_id)\n", 120 | "s1.item" 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "id": "e27e792f", 126 | "metadata": {}, 127 | "source": [ 128 | "### Fetching theme for site" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": 5, 134 | "id": "c8b2a35b", 135 | "metadata": {}, 136 | "outputs": [ 137 | { 138 | "data": { 139 | "text/plain": [ 140 | "{'header': {'background': '#4c4c4c', 'text': '#ffffff'}, 'body': {'background': '#ffffff', 'text': '#5c5c5c', 'link': '#0079c1'}, 'button': {'background': '#0079c1', 'text': '#ffffff'}, 'logo': {'small': 'https://www.arcgis.com/sharing/rest/content/items/a043a0205d644badadb88b7cd9256526/data', 'link': 'https://octo.dc.gov/sites/default/files/dc/sites/octo/multimedia_content/images/OpenData-HeaderLogo-WhiteText-2.png'}, 'fonts': {'base': {'url': '', 'family': 'Avenir Next'}, 'heading': {'url': '', 'family': 'Avenir Next'}}}" 141 | ] 142 | }, 143 | "execution_count": 5, 144 | "metadata": {}, 145 | "output_type": "execute_result" 146 | } 147 | ], 148 | "source": [ 149 | "theme = s1.theme\n", 150 | "theme" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 6, 156 | "id": "d95b7ddb", 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "data": { 161 | "text/plain": [ 162 | "'#ffffff'" 163 | ] 164 | }, 165 | "execution_count": 6, 166 | "metadata": {}, 167 | "output_type": "execute_result" 168 | } 169 | ], 170 | "source": [ 171 | "theme.body.background" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 7, 177 | "id": "0abfb390", 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "data": { 182 | "text/plain": [ 183 | "'#5c5c5c'" 184 | ] 185 | }, 186 | "execution_count": 7, 187 | "metadata": {}, 188 | "output_type": "execute_result" 189 | } 190 | ], 191 | "source": [ 192 | "theme.body.text" 193 | ] 194 | }, 195 | { 196 | "cell_type": "markdown", 197 | "id": "caf9bb44", 198 | "metadata": {}, 199 | "source": [ 200 | "### Updating theme for a site" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 8, 206 | "id": "561b9b10", 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [ 210 | "theme.body.background = '#c90076'" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 9, 216 | "id": "d54cdaad", 217 | "metadata": {}, 218 | "outputs": [], 219 | "source": [ 220 | "theme.body.text = '#eeeeee'" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 10, 226 | "id": "8c2d659d", 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "True" 233 | ] 234 | }, 235 | "execution_count": 10, 236 | "metadata": {}, 237 | "output_type": "execute_result" 238 | } 239 | ], 240 | "source": [ 241 | "s1.update_theme(theme)" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "id": "6260e30a", 247 | "metadata": {}, 248 | "source": [ 249 | "By refreshing this site, we then see the theme color of the site has been updated." 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "id": "08f35abe", 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [] 259 | } 260 | ], 261 | "metadata": { 262 | "kernelspec": { 263 | "display_name": "Python 3 (ipykernel)", 264 | "language": "python", 265 | "name": "python3" 266 | }, 267 | "language_info": { 268 | "codemirror_mode": { 269 | "name": "ipython", 270 | "version": 3 271 | }, 272 | "file_extension": ".py", 273 | "mimetype": "text/x-python", 274 | "name": "python", 275 | "nbconvert_exporter": "python", 276 | "pygments_lexer": "ipython3", 277 | "version": "3.7.11" 278 | } 279 | }, 280 | "nbformat": 4, 281 | "nbformat_minor": 5 282 | } 283 | -------------------------------------------------------------------------------- /examples/For arcgishub library/Working with pages of a site.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "sys.path.append(\"../../\")\n", 11 | "\n", 12 | "from arcgishub import hub" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "myhub = hub.Hub(\"https://www.arcgis.com\", 'aturner')" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "### Fetch site" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "s = myhub.sites.get('52ec55a018dc43cb896409f071be207d')\n", 38 | "s.item" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "### View all pages of a site" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "You can view pages of a site by using either the `all_pages` property of a site, or by using the `search()` method. An example using the property is demonstrated below." 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "s.pages.search()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "### Fetch a page" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [ 77 | "new_page = myhub.pages.get('1c75da020b2f4943a3f657ef59fc1bc8')\n", 78 | "new_page.item" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "metadata": {}, 84 | "source": [ 85 | "### Link a page" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "Linking an unlinking pages is possible by calling the `link()` or `unlink()` methods on `pages` and passing the page object of the page to link/unlink." 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "s.pages.link(new_page, slug='linked page space')\n", 102 | "s.pages.search()" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "### Unlink a page" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [ 118 | "s.pages.unlink(new_page)\n", 119 | "s.pages.search()" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "### Add a page" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": null, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "p1 = s.pages.add(title='hubpy page')\n", 136 | "p1.item" 137 | ] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "metadata": {}, 142 | "source": [ 143 | "### Clone page in same site" 144 | ] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "execution_count": null, 149 | "metadata": {}, 150 | "outputs": [], 151 | "source": [ 152 | "cloned_page = s.pages.clone(p1)\n", 153 | "cloned_page" 154 | ] 155 | }, 156 | { 157 | "cell_type": "markdown", 158 | "metadata": {}, 159 | "source": [ 160 | "### Update a page - Title" 161 | ] 162 | }, 163 | { 164 | "cell_type": "markdown", 165 | "metadata": {}, 166 | "source": [ 167 | "Let's update the title of the newly cloned page" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "cloned_page.update(page_properties={'title':'Cloned hubpy page'})\n", 177 | "cloned_page" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [ 186 | "s.pages.search()" 187 | ] 188 | }, 189 | { 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "We verify that the title of the cloned page has been successfully updated. We now update the slug for this page.\n", 194 | "\n", 195 | "### Update a page - Slug" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "cloned_page.update(slug='cloned-hubpy-page')\n", 205 | "cloned_page.slug" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "metadata": {}, 211 | "source": [ 212 | "### Delete a page" 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "We will now delete the cloned page.\n", 220 | "\n", 221 | "Note that to verify the delete in the pages of the site, you will have to fetch the site object again as shown below." 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "metadata": {}, 228 | "outputs": [], 229 | "source": [ 230 | "cloned_page.delete()" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": null, 236 | "metadata": {}, 237 | "outputs": [], 238 | "source": [ 239 | "s = myhub.sites.get('52ec55a018dc43cb896409f071be207d')\n", 240 | "s.pages.search()" 241 | ] 242 | }, 243 | { 244 | "cell_type": "markdown", 245 | "metadata": {}, 246 | "source": [ 247 | "### Clone page in another site" 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": null, 253 | "metadata": {}, 254 | "outputs": [], 255 | "source": [ 256 | "i2 = myhub.initiatives.get('66dde827deed4f26ae5d842aba053b67')\n", 257 | "i2.item" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": null, 263 | "metadata": {}, 264 | "outputs": [], 265 | "source": [ 266 | "s2 = myhub.sites.get(i2.site_id)" 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": null, 272 | "metadata": {}, 273 | "outputs": [], 274 | "source": [ 275 | "s2.pages.search()" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": null, 281 | "metadata": {}, 282 | "outputs": [], 283 | "source": [ 284 | "p_cloned = s2.pages.clone(p1)\n", 285 | "p_cloned" 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": null, 291 | "metadata": {}, 292 | "outputs": [], 293 | "source": [ 294 | "s2.pages.search()" 295 | ] 296 | } 297 | ], 298 | "metadata": { 299 | "kernelspec": { 300 | "display_name": "Python 3 (ipykernel)", 301 | "language": "python", 302 | "name": "python3" 303 | }, 304 | "language_info": { 305 | "codemirror_mode": { 306 | "name": "ipython", 307 | "version": 3 308 | }, 309 | "file_extension": ".py", 310 | "mimetype": "text/x-python", 311 | "name": "python", 312 | "nbconvert_exporter": "python", 313 | "pygments_lexer": "ipython3", 314 | "version": "3.9.6" 315 | } 316 | }, 317 | "nbformat": 4, 318 | "nbformat_minor": 2 319 | } 320 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | seaborn -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from codecs import open 3 | from os import path 4 | 5 | here = path.abspath(path.dirname(__file__)) 6 | 7 | setup( 8 | name='arcgishub', 9 | 10 | # Versions should comply with PEP440. For a discussion on single-sourcing 11 | # the version across setup.py and the project code, see 12 | # https://packaging.python.org/en/latest/single_source_version.html 13 | 14 | version='2.1.0', 15 | description='ArcGIS Hub Python API', 16 | long_description='Python API to automate your Hub processes', 17 | #url='http://pypi.python.org/pypi/TowelStuff/', 18 | 19 | #Author details 20 | author='Esri', 21 | 22 | # Choose your license 23 | license='Proprietary License', 24 | 25 | # See https://pypi.python.org/pypi?%3Aaction=list_classifiers 26 | classifiers=[ 27 | # How mature is this project? Common values are 28 | # 3 - Alpha 29 | # 4 - Beta 30 | # 5 - Production/Stable 31 | 'Development Status :: 4', 32 | 33 | # Indicate who your project is intended for 34 | 'Intended Audience :: Developers, Hub Customers', 35 | 36 | # Pick your license as you wish (should match "license" above) 37 | 'License :: Other/Proprietary License', 38 | 39 | # Specify the Python versions you support here. In particular, ensure 40 | # that you indicate whether you support Python 2, Python 3 or both. 41 | 'Programming Language :: Python :: 3.7', 42 | ], 43 | 44 | # What does your project relate to? 45 | keywords='gis geographic spatial hub arcgis initiatives', 46 | 47 | packages=find_packages(), 48 | 49 | # List run-time dependencies here. These will be installed by pip when 50 | # your project is installed. For an analysis of "install_requires" vs pip's 51 | # requirements files see: 52 | # https://packaging.python.org/en/latest/requirements.html 53 | install_requires=['six', 'arcgis>2.0.0'], 54 | ) 55 | --------------------------------------------------------------------------------