I am working on a Python script to manage ArcGIS Server services (publish new services, update existing services, delete old services, etc.) in batch across multiple environments (e.g. dev, test and production) and instances (2+ per environment).
To publish services, you can use ArcPy and AGS connection files, but to do anything beyond that (e.g. list existing services, start/stop/delete services), you need to use the AGS Admin REST API, which uses token-based authentication, and to get a token you need to submit the user's name and password.
Having to specify the server URL, username and password each time would be tedious for the user, especially if they are working with more than one AGS instance at a time, as my script does. I'd much prefer if they could just use their preexisting AGS connection files instead, which they need for publishing regardless.
Is there any way to get the connection info (e.g. server URL, username, password) from an AGS connection (.ags
) file programmatically -- ideally with Python? arcpy.Describe
considers them dumb files and can't do anything with them.
If there's no way to do that then I suppose I will have to require an additional configuration step to generate and store the tokens locally for a long duration as it would be too cumbersome to have to prompt the user for credentials for each AGS instance every time they use the script.