Possible to tell if a feature service is "hosted" in environment or not?

730
2
Jump to solution
06-30-2022 09:25 AM
Jay_Gregory
Occasional Contributor III

I can easily get a list of all feature services in my AGOL environment

fs = gis.content.search(query="type:service", max_items=10000)

From these results, I am curious if there is any easy way to understand if a feature service is "hosted" or not.  In other words, how can I tell if a feature service was created by a user uploading or creating data (csv, shapefile, etc.) or if a user added a feature service from an existing arcgis url (new item-->from url-->paste in REST endpoint-->etc).  

I know I can find this information out by looking at the items in our AGOL instance, but want to be able to do this programmatically.  

Any tips?

1 Solution

Accepted Solutions
Clubdebambos
Occasional Contributor III

Hi @Jay_Gregory 

Each item has a typeKeywords property which is a list. If it is a Hosted Service there is a 'Hosted Service' string in this list as shown below.

 

print(fs.typeKeywords

['ArcGIS Server', 'Data', 'Feature Access', 'Feature Service', 'Metadata', 'providerSDS', 'Service', 'Hosted Service']

 

The below will filter out items that has the 'Hosted Service' keyword.

 

from arcgis.gis import GIS

gis = GIS("home")

fs_list = gis.content.search(query="type:service", max_items=10000)

hosted = [fs for fs in fs_list if 'Hosted Service' in fs.typeKeywords]

print(hosted)

 

If you print out the keywords for various item types you might be able use the same method, or use in tandem with other filters, to get the information you need. 

~ learn.finaldraftmapping.com

View solution in original post

2 Replies
Clubdebambos
Occasional Contributor III

Hi @Jay_Gregory 

Each item has a typeKeywords property which is a list. If it is a Hosted Service there is a 'Hosted Service' string in this list as shown below.

 

print(fs.typeKeywords

['ArcGIS Server', 'Data', 'Feature Access', 'Feature Service', 'Metadata', 'providerSDS', 'Service', 'Hosted Service']

 

The below will filter out items that has the 'Hosted Service' keyword.

 

from arcgis.gis import GIS

gis = GIS("home")

fs_list = gis.content.search(query="type:service", max_items=10000)

hosted = [fs for fs in fs_list if 'Hosted Service' in fs.typeKeywords]

print(hosted)

 

If you print out the keywords for various item types you might be able use the same method, or use in tandem with other filters, to get the information you need. 

~ learn.finaldraftmapping.com
Jay_Gregory
Occasional Contributor III

Thank you! I knew it was somewhere in there! dir(item) just returns too many properties 🙂

0 Kudos