In [1]:
"""
This demo will show users how they can ensure all map services have WMS
enabled on each service
"""
import arcrest
user = ""
password = ""
# example org_url: https://myorg.site.com/arcgis
org_url = "https://myorg.com/arcgis"
admin_url = "{org}/admin".format(org=org_url)
token_url = "{admin}/generateToken".format(admin=admin_url)
sh = arcrest.AGSTokenSecurityHandler(username=user, password=password,
                                     org_url=org_url,
                                     token_url=token_url)
ags_admin = arcrest.manageags.AGSAdministration(url=admin_url,
                                                securityHandler=sh,
                                                initialize=True)
services = ags_admin.services
for folder in services.folders:
    print("In Folder, %s" % folder)
    services.folderName = folder
    for s in services.services:
        print ("===============================")
        print ("Examining Service: {0}".format(s.serviceName))
        if s.type.lower() == "mapserver":
            exts = s.extensions
            for ext in exts:
                if ext.typeName in ['WMSServer'] and \
                   ext.enabled == False:
                    ext.enabled = True
                    print(" - Turning on WMS!")
                    s.modifyExtensions(exts)
                    break


In Folder, cachetest
In Folder, countries
===============================
Examining Service: countriesoftheworld
 - Turning on WMS!
===============================
Examining Service: twotypes
 - Turning on WMS!
In Folder, Hosted
===============================
Examining Service: ooospde
===============================
Examining Service: vc3test
===============================
Examining Service: vectortile1
===============================
Examining Service: vs_data
In Folder, mptest
===============================
Examining Service: counties_cache_service
 - Turning on WMS!
===============================
Examining Service: PointsOnTheWind
 - Turning on WMS!
In Folder, System
===============================
Examining Service: CachingControllers
===============================
Examining Service: CachingTools
===============================
Examining Service: PublishingTools
===============================
Examining Service: ReportingTools
===============================
Examining Service: SceneCachingControllers
===============================
Examining Service: SceneCachingTools
===============================
Examining Service: SpatialAnalysisTools
===============================
Examining Service: SyncTools
In Folder, Utilities
===============================
Examining Service: Geometry
===============================
Examining Service: PrintingTools
===============================
Examining Service: Search
In Folder, /
===============================
Examining Service: Counties
 - Turning on WMS!
===============================
Examining Service: SampleWorldCities

In [ ]: