ArcGIS API for Python - How to get() a service

1087
4
Jump to solution
03-04-2021 02:54 PM
JoanneMcGraw
Occasional Contributor III

Hello,

Similar to https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-how-to-manage-da..., now I'm trying to figure out how to get a service object so I can delete() it.

To recap, I am working with a stand-alone site consisting of two 10.8.1 ArcGIS Servers; i.e., no Portal. I have done this in the past for 10.4.1 using the REST API but am trying to do same with the newer "ArcGIS API for Python". I'm new to this, having trouble working through the documentation and not finding much in the way of examples.

I have an arcgis.gis.server.Server object instantiated and can list(<folder_name>) on its services to receive a list of all the services that exist in the specified folder.

However, the documentation suggests that using a ServicesDirectory (https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html#arcgis.gis.server.catalog....) will allow me to get() a service directly. I have been unable to get this to work. I can't even get my ServicesDirectory's object to list(<folder_name>), using the same folder_name that works with the Server object's list. The list returned is always empty.

Again...anything that might help is appreciated.

Cheers,
jtm

0 Kudos
2 Solutions

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

If you want to delete a service, you need to go through the Admin API and not the REST Services endpoint. 

If you are getting a list of services, then you have the service already, you just need to grab it from the list.  Iterate through the list to find the one you are interested in.

View solution in original post

0 Kudos
fpr
by
New Contributor
0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

If you want to delete a service, you need to go through the Admin API and not the REST Services endpoint. 

If you are getting a list of services, then you have the service already, you just need to grab it from the list.  Iterate through the list to find the one you are interested in.

0 Kudos
fpr
by
New Contributor
0 Kudos
JoanneMcGraw
Occasional Contributor III

First, "Thank you!" to both Joshua and Fred for taking the time to reply.

I'm not able to mark both as a solution (although each are) so I'll choose Fred's because it gave me more information than I had already learned...particularly the link to https://developers.arcgis.com/python/guide/managing-your-gis-servers/ (which I hadn't found).

Having said that, an overriding question that I have regarding using ArcGIS API for Python hasn't been answered, but after re-reading my posts I realize I may not have been clear. So, I'll accept Fred's reponse but will also start a new thread with an code example to illustrate what I'm fundamentally struggling to understand.

Cheers,

jtm

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

@JoanneMcGraw, in the new GeoNet (aka Esri Community) platform, multiple replies can be marked as the solution, if you want.

0 Kudos