方法
Portal for ArcGIS アイテム間の依存関係を特定しなくてはならない場合があります。 たとえば、データ クリーンナップ時には、Web アプリと関連 Web マップの削除が必要になることがあります。 これらの依存関係は手動で確認ですが、面倒な作業です。 このプロセスは、管理者権限を使用してプログラム的に実行することもできます。その場合は、ArcGIS API for Python の dependent_upon() 関数と dependent_to 関数を使用します。
ArcGIS API for Python を使用し、Portal for ArcGIS の依存関係を特定するには、以下の手順を実行します。
from arcgis.gis import GIS from IPython.display import display
source = GIS("<portalurl>", "<admin_user>", "<admin_password>") source_users = source.users.search(query=None, sort_field='username', sort_order='asc', max_users=100, outside_org=False, exclude_system=True) source_items_by_id = {} print('User list: Role')
for user in source_users: print(user.username + "\t:\t" + str(user.role))
for user in source_users: num_items = 0 num_folders = 0 print("Collecting item ids for {}".format(user.username), end="\n\n") user_content = user.items()
for item in user_content: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to()))
folders = user.folders for folder in folders: num_folders += 1 folder_items = user.items(folder=folder['title']) for item in folder_items: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) print("Number of folders {} # Number of items {} # Number of users {}".format(str(num_folders), str(num_items), len(source_users)))
以下に完全なスクリプトを示します。
from arcgis.gis import GIS from IPython.display import display source = GIS("https://test.domain.com/portal", "portaladmin", "portaladmin") source_users = source.users.search(query=None, sort_field='username', sort_order='asc', max_users=100, outside_org=False, exclude_system=True) source_items_by_id = {} print('User list: Role') for user in source_users: print(user.username + "\t:\t" + str(user.role)) for user in source_users: num_items = 0 num_folders = 0 print("Collecting item ids for {}".format(user.username), end="\n\n") user_content = user.items() for item in user_content: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) folders = user.folders for folder in folders: num_folders += 1 folder_items = user.items(folder=folder['title']) for item in folder_items: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) print("Number of folders {} # Number of items {} # Number of users {}".format(str(num_folders), str(num_items), len(source_users)))
ArcGIS エキスパートのサポートを受ける
Esri Support アプリのダウンロード