Skip to content

Commit 4e6aa87

Browse files
AtmaManirohitgeo
authored andcommitted
V101 publish packages & clone samples (#77)
* content and notebook demonstrating publishing of packages as web layers * added sample showing how to publish packages as web layers * updated clone portals sample
1 parent fab2e8d commit 4e6aa87

File tree

6 files changed

+416
-48
lines changed

6 files changed

+416
-48
lines changed

guide/02 API Overview/Release notes.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"\n",
1010
"* BUG-000101507 gis.groups.search returns incorrect results if the User is an owner of more than 100 groups.\n",
1111
"* Enabled building initial cache when publishing vector tile packages\n",
12-
"* Fixed bug in creating new users on Portal 10.5 or newer\n",
12+
"* Fixed bug in creating new users on ArcGIS Online or Portal for ArcGIS 10.5 or newer\n",
1313
"* Fix to ignore values like size of -1 when initializing item objects\n",
1414
"* Reorder batch geocoding results to match input array\n",
1515
"\n",
@@ -56,7 +56,7 @@
5656
"name": "python",
5757
"nbconvert_exporter": "python",
5858
"pygments_lexer": "ipython3",
59-
"version": "3.5.2"
59+
"version": "3.6.0"
6060
}
6161
},
6262
"nbformat": 4,

samples/03 Org Administrators/Clone Portal Users, Groups and Content.ipynb

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"source": [
1818
"# Clone Portal users, groups and content\n",
1919
"\n",
20-
"This sample notebook can be used for cloning an entire Portal, from maybe a staging to a production environment. It clones the users, groups and the content. It does not copy over services and data though, and works at the tier of Portal items."
20+
"This sample notebook can be used for cloning a portal, from say, a staging to a production environment. It clones the users, groups and the content. It does not copy over services and data though, and works at the tier of portal items."
2121
]
2222
},
2323
{
@@ -48,10 +48,8 @@
4848
},
4949
"outputs": [],
5050
"source": [
51-
"source = GIS(\"https://dev003328.esri.com/portal\", \"admin\", \"esri.agp\", verify_cert=False)\n",
52-
"target = GIS(\"https://dev003327.esri.com/portal\", \"admin\", \"esri.agp\", verify_cert=False)\n",
53-
"# source = GIS(\"portal or org url\", \"username\", \"password\")\n",
54-
"# target = GIS(\"portal or org url\", \"username\", \"password\")\n",
51+
"source = GIS(\"portal url\", \"username\", \"password\")\n",
52+
"target = GIS(\"target portal url\", \"username\", \"password\")\n",
5553
"target_admin_username = 'admin'"
5654
]
5755
},
@@ -211,9 +209,10 @@
211209
}
212210
],
213211
"source": [
214-
"for srcuser in sourceusers:\n",
215-
" if not srcuser.username in systemusers:\n",
216-
" if srcuser.username is not target_admin_username: #don't delete the account used to connect\n",
212+
"for srcuser in source_users:\n",
213+
" if not srcuser.username in system_users:\n",
214+
" #don't delete the account used to connect\n",
215+
" if srcuser.username != target_admin_username:\n",
217216
" try:\n",
218217
" targetusr = target.users.get(srcuser.username)\n",
219218
" if targetusr is not None:\n",
@@ -243,20 +242,20 @@
243242
"def copy_user(target, user, password):\n",
244243
" # See if the user has firstName and lastName properties\n",
245244
" try:\n",
246-
" firstname = user.firstName\n",
247-
" lastname = user.lastName\n",
245+
" first_name = user.firstName\n",
246+
" last_name = user.lastName\n",
248247
" except:\n",
249248
" # if not, split the fullName\n",
250-
" fullName = user.fullName\n",
251-
" firstname = fullName.split()[0]\n",
249+
" full_name = user.fullName\n",
250+
" first_name = full_name.split()[0]\n",
252251
" try:\n",
253-
" lastname = fullName.split()[1]\n",
252+
" last_name = full_name.split()[1]\n",
254253
" except:\n",
255-
" lastname = 'NoLastName'\n",
254+
" last_name = 'NoLastName'\n",
256255
"\n",
257256
" try:\n",
258257
" # create user\n",
259-
" target_user = target.users.create(user.username, password, firstname, lastname,\n",
258+
" target_user = target.users.create(user.username, password, first_name, last_name,\n",
260259
" user.email, user.description, user.role)\n",
261260
"\n",
262261
" # update user properties\n",
@@ -344,7 +343,7 @@
344343
"source": [
345344
"ignore_list = [target_admin_username,'system_publisher', 'esri_nav', 'esri_livingatlas', \n",
346345
" 'esri_boundaries', 'esri_demographics']\n",
347-
"for user in sourceusers:\n",
346+
"for user in source_users:\n",
348347
" if not user.username in ignore_list:\n",
349348
" print(\"Creating user: \" + user.username)\n",
350349
" copy_user(target, user, 'TestPassword@123')"
@@ -430,8 +429,8 @@
430429
}
431430
],
432431
"source": [
433-
"targetusers = target.users.search()\n",
434-
"targetusers"
432+
"target_users = target.users.search()\n",
433+
"target_users"
435434
]
436435
},
437436
{
@@ -483,8 +482,8 @@
483482
}
484483
],
485484
"source": [
486-
"sourcegroups = source.groups.search()\n",
487-
"sourcegroups"
485+
"source_groups = source.groups.search()\n",
486+
"source_groups"
488487
]
489488
},
490489
{
@@ -511,8 +510,8 @@
511510
}
512511
],
513512
"source": [
514-
"targetgroups = target.groups.search()\n",
515-
"targetgroups"
513+
"target_groups = target.groups.search()\n",
514+
"target_groups"
516515
]
517516
},
518517
{
@@ -531,9 +530,9 @@
531530
"outputs": [],
532531
"source": [
533532
"groups_to_ignore = ['Basemaps']\n",
534-
"for tg in targetgroups:\n",
533+
"for tg in target_groups:\n",
535534
" if tg.title not in groups_to_ignore:\n",
536-
" for sg in sourcegroups:\n",
535+
" for sg in source_groups:\n",
537536
" if sg.title == tg.title and (not tg.owner in systemusers):\n",
538537
" print(\"Cleaning up group {} in target Portal...\".format(tg.title))\n",
539538
" tg.delete()\n",
@@ -667,8 +666,8 @@
667666
}
668667
],
669668
"source": [
670-
"targetgroups = target.groups.search()\n",
671-
"targetgroups"
669+
"target_groups = target.groups.search()\n",
670+
"target_groups"
672671
]
673672
},
674673
{
@@ -722,8 +721,9 @@
722721
"metadata": {},
723722
"source": [
724723
"Copying items consists of multiple steps. The following section of the sample does the following\n",
725-
" 1. Create a dictionary of itemIds and item objects for each user in each folder\n",
726-
" 2. Prepare sharing information for each item"
724+
"\n",
725+
" 1. Create a dictionary of itemIds and `Item` objects for each user in each folder\n",
726+
" 2. Prepare sharing information for each item"
727727
]
728728
},
729729
{
@@ -800,18 +800,18 @@
800800
],
801801
"source": [
802802
"source_items_by_id = {}\n",
803-
"for user in sourceusers:\n",
804-
" if not user.username in systemusers: # ignore any 'system' Portal users\n",
803+
"for user in source_users:\n",
804+
" if not user.username in system_users: # ignore any 'system' Portal users\n",
805805
" print(\"Collecting item ids for {}...\".format(user.username))\n",
806-
" usercontent = user.items()\n",
806+
" user_content = user.items()\n",
807807
" # Copy item ids from root folder first\n",
808-
" for item in usercontent:\n",
808+
" for item in user_content:\n",
809809
" source_items_by_id[item.itemid] = item \n",
810810
" # Copy item ids from folders next\n",
811811
" folders = user.folders\n",
812812
" for folder in folders:\n",
813-
" folderitems = user.items(folder=folder['title'])\n",
814-
" for item in folderitems:\n",
813+
" folder_items = user.items(folder=folder['title'])\n",
814+
" for item in folder_items:\n",
815815
" source_items_by_id[item.itemid] = item "
816816
]
817817
},
@@ -831,12 +831,12 @@
831831
},
832832
"outputs": [],
833833
"source": [
834-
"for group in sourcegroups:\n",
834+
"for group in source_groups:\n",
835835
" if group.title not in groups_to_ignore:\n",
836-
" if not group.owner in systemusers:\n",
836+
" if not group.owner in system_users:\n",
837837
" target_group_id = copied_groups[group.groupid]\n",
838838
" for group_item in group.content():\n",
839-
" if not group_item.owner in systemusers:\n",
839+
" if not group_item.owner in system_users:\n",
840840
" try:\n",
841841
" item = source_items_by_id[group_item.itemid]\n",
842842
" if item is not None:\n",
@@ -5580,7 +5580,7 @@
55805580
" print(\"**************\\n\"+user.username)\n",
55815581
" usercontent = user.items()\n",
55825582
" folders = user.folders\n",
5583-
" for item in usercontent:\n",
5583+
" for item in user_content:\n",
55845584
" try:\n",
55855585
" copied_item = copy_item(target, user, None, item)\n",
55865586
" if copied_item is not None:\n",
@@ -5598,12 +5598,10 @@
55985598
" print(\"Error copying \" + item.title)\n",
55995599
"\n",
56005600
" for folder in folders:\n",
5601-
" target.content.create_folder(folder['title'], user)\n",
5602-
" folderitems = user.items(folder['title'])\n",
5601+
" target.content.create_folder(folder, user)\n",
5602+
" folder_items = user.items(folder['title'])\n",
56035603
" for item in folderitems:\n",
56045604
" try:\n",
5605-
" #display(item)\n",
5606-
" #print(item.__repr__())\n",
56075605
" copied_item = copy_item(target, user, folder['title'], item)\n",
56085606
" if copied_item is not None:\n",
56095607
" copied_items[item.itemid] = copied_item.itemid\n",
@@ -5622,8 +5620,8 @@
56225620
" # Copy the related items for this user (if specified)\n",
56235621
" if relationships:\n",
56245622
" for folder in folders:\n",
5625-
" folderitems = usercontent[folder]\n",
5626-
" for item in folderitems:\n",
5623+
" folder_items = user_content[folder]\n",
5624+
" for item in folder_items:\n",
56275625
" try:\n",
56285626
" copy_relationships(target, copied_items, item, \n",
56295627
" relationships, user, folder)\n",
@@ -5634,7 +5632,7 @@
56345632
],
56355633
"metadata": {
56365634
"kernelspec": {
5637-
"display_name": "Python [default]",
5635+
"display_name": "Python 3",
56385636
"language": "python",
56395637
"name": "python3"
56405638
},
@@ -5648,7 +5646,7 @@
56485646
"name": "python",
56495647
"nbconvert_exporter": "python",
56505648
"pygments_lexer": "ipython3",
5651-
"version": "3.5.2"
5649+
"version": "3.6.0"
56525650
}
56535651
},
56545652
"nbformat": 4,

0 commit comments

Comments
 (0)