<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035181#M5694</link>
    <description>Thanks for your reply! When I do an item search and return some list lyrs:&lt;BR /&gt;for lyr in lyrs:&lt;BR /&gt;lyr.url&lt;BR /&gt;&lt;BR /&gt;This will return the url for service layers, as you say. For example urls&lt;BR /&gt;for Feature service layers, or the external url for like a WMS layer.&lt;BR /&gt;While it is easy to see which is an internal url (Hosted feature service)&lt;BR /&gt;and which is an external one (WMS service), is there a way to determine&lt;BR /&gt;this programmatically? I want to differentiate between feature services&lt;BR /&gt;that are hosted in my organization and reference layers that are also&lt;BR /&gt;services.&lt;BR /&gt;</description>
    <pubDate>Wed, 10 Mar 2021 22:28:37 GMT</pubDate>
    <dc:creator>AnnaGabrielli</dc:creator>
    <dc:date>2021-03-10T22:28:37Z</dc:date>
    <item>
      <title>Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035162#M5692</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am creating a program using the ArcGIS Python API to go through all content within my organization (ArcGIS Online and Portal) and "audit" it: returning information like the item ID, how it is shared, any groups it is in, whether or not it is delete protected, created and modified dates, etc.&lt;/P&gt;&lt;P&gt;I would like to also know whether content is hosted within my organization or if it is a referenced service layer. Is there a way to do this with the API? There does not seem to be a corresponding item property, the same way there is item.id, item.url, etc, and I have not been able to find any documentation on how to find this.&lt;/P&gt;&lt;P&gt;Thanks for any help or documentation links!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 22:00:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035162#M5692</guid>
      <dc:creator>AnnaGabrielli</dc:creator>
      <dc:date>2021-03-10T22:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035174#M5693</link>
      <description>&lt;P&gt;I'm assuming that you mean a layer you've added from another org, not a basemap reference layer?&lt;/P&gt;&lt;P&gt;To find out where the layer is originating from, you can call the &lt;STRONG&gt;url&lt;/STRONG&gt; property on most operational layers.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyrs = gis.content.search('some search for layers')

for lyr in lyrs:
    print(l.url)&lt;/LI-CODE&gt;&lt;P&gt;If a content item isn't a service, you'll just get &lt;STRONG&gt;None&lt;/STRONG&gt;, but otherwise, you'll get the origin URL of the service.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1615414743591.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/8125i59D5040BACCFE7F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1615414743591.png" alt="jcarlson_0-1615414743591.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 22:19:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035174#M5693</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-03-10T22:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035181#M5694</link>
      <description>Thanks for your reply! When I do an item search and return some list lyrs:&lt;BR /&gt;for lyr in lyrs:&lt;BR /&gt;lyr.url&lt;BR /&gt;&lt;BR /&gt;This will return the url for service layers, as you say. For example urls&lt;BR /&gt;for Feature service layers, or the external url for like a WMS layer.&lt;BR /&gt;While it is easy to see which is an internal url (Hosted feature service)&lt;BR /&gt;and which is an external one (WMS service), is there a way to determine&lt;BR /&gt;this programmatically? I want to differentiate between feature services&lt;BR /&gt;that are hosted in my organization and reference layers that are also&lt;BR /&gt;services.&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Mar 2021 22:28:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035181#M5694</guid>
      <dc:creator>AnnaGabrielli</dc:creator>
      <dc:date>2021-03-10T22:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035205#M5695</link>
      <description>&lt;P&gt;I suppose if you stored your hosting server as an attribute, you could simply check&lt;/P&gt;&lt;PRE&gt;my_url = 'some-server-url'&lt;BR /&gt;&lt;BR /&gt;if lyr.url == my_url:&lt;BR /&gt;    print('internal')&lt;BR /&gt;else:&lt;BR /&gt;    print('external')&lt;/PRE&gt;&lt;P&gt;Are you doing this on AGOL or a private Portal? There are some differences in what we're able to do depending on which.&lt;/P&gt;&lt;P&gt;I &lt;EM&gt;have&lt;/EM&gt; noticed that the most recent update to AGOL added this sort of thing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1615416713576.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/8146i81F73C103A51BD7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1615416713576.png" alt="jcarlson_0-1615416713576.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So there does seem to be some way to track whether an item is coming from an outside org...&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 22:52:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035205#M5695</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-03-10T22:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035618#M5700</link>
      <description>&lt;P&gt;Thanks for your replies! I found that one can determine if the item type matches any possible hosted types (all potential types can be found &lt;A href="https://enterprise.arcgis.com/en/portal/latest/use/hosted-web-layers.htm" target="_self"&gt;here&lt;/A&gt;) and then look for the enterprise specific 'Hosted' directory in the url, see below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;potential_hosted_types = list('all potential types here')
#loop through the list to see if our item type is a match
for potential_type in potential_hosted_types:
   if item.type in potential_type:
      maybe_hosted = True
   else:
      maybe_hosted = False

#See if the item is in the Hosted directory
if maybe_hosted == True:
   if 'Hosted' in item.url:
      item_hosted = True
   else:
      item_hosted = False
else:
   item_hosted = False
&lt;/LI-CODE&gt;&lt;P&gt;I am not sure how to do something similar for items in ArcGIS online since there is no Hosted directory.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 19:05:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035618#M5700</guid>
      <dc:creator>AnnaGabrielli</dc:creator>
      <dc:date>2021-03-11T19:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035837#M5705</link>
      <description>&lt;P&gt;Hi Anna,&lt;/P&gt;&lt;P&gt;You can list all feature layers hosted using gis.admin module.&lt;/P&gt;&lt;P&gt;See sample below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from arcgis.gis import GIS
gis = GIS("https://votreNomDomaine/portal", "login", "password")

server = gis.admin.servers.list()[0]
count=1
for service in server.services.list('Hosted'):
    print('{} {}'.format(count, service)) 
    count+=1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Hope this help you,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 08:18:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1035837#M5705</guid>
      <dc:creator>FrédéricPRALLY</dc:creator>
      <dc:date>2021-03-12T08:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiating between hosted and reference service items in ArcGIS Online and Portal with the ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1036002#M5709</link>
      <description>&lt;P&gt;Hi Anna,&lt;/P&gt;&lt;P&gt;Another more elegant code is to check if the property&amp;nbsp;typeKeywords of the item has the text 'hosted Service' include in his list.&lt;/P&gt;&lt;P&gt;Retrieve code below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from arcgis.gis import GIS
gis = GIS("https://votreNomDomaine/portal", "login", "password")

items = gis.content.search('*',item_type="Feature Layer", max_items=25)
itemsHosted = [item.title for item in items if 'Hosted Service' in item.typeKeywords]
print(itemsHosted)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this help you,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 16:48:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/differentiating-between-hosted-and-reference/m-p/1036002#M5709</guid>
      <dc:creator>FrédéricPRALLY</dc:creator>
      <dc:date>2021-03-12T16:48:46Z</dc:date>
    </item>
  </channel>
</rss>

