Select to view content in your preferred language

Fantastic GP Team

2436
2
08-01-2011 03:39 PM
TedCronin
MVP Honored Contributor
>>> help(_server_admin)
Help on package _server_admin:

NAME
    _server_admin

FILE
    c:\program files\arcgis\server\arcpy\_server_admin\__init__.py

DESCRIPTION
    This is a Python binding to the ArcGIS REST Server API, similar to the
    JavaScript or Flex API in program structure as well as in the way it
    interfaces with ArcGIS servers.

    Getting Started with Rest Administration
    ========================================

    A simple example of connecting to a server:

       >>> import _server_admin
       >>> catalog = _server_admin.Catalog("http://sampleserver1.arcgisonline.co
m/arcgis/rest/services")
       >>> catalog.services
       [<GeometryServer ('http://sampleserver1.arcgisonline.com/arcgis/rest/serv
ices/Geometry/GeometryServer/?f=json')>]

    Getting a service from a catalog:

       >>> locator = catalog.Locators.ESRI_Geocode_USA
       >>> locator.url
       'http://sampleserver1.arcgisonline.com/arcgis/rest/services/Locators/ESRI
_Geocode_USA/GeocodeServer/?f=json'
       >>> locator.FindAddressCandidates(Address="380 NEW YORK ST", City="Redlan
ds", State="CA")
       <FindAddressCandidatesResult('http://sampleserver1.arcgisonline.com/arcgi
s/rest/services/Locators/ESRI_Geocode_USA/GeocodeServe...')>
       >>> candidates.candidates[0]
       {'attributes': {}, 'score': 81, 'location': POINT(-117.19568 34.05752), '
address': '380 NEW YORK ST, REDLANDS, CA, 92373'}

    Getting a service from a URL:

       >>> service = _server_admin.GPService("http://sampleserver1.arcgisonline.
com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer")
       >>> service.url
       'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESR
I_Currents_World/GPServer/?f=json'

    Inspecting and executing a geoprocessing service:

       >>> service.tasks
       [<GPTask('http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Spec
ialty/ESRI_Currents_World/GPServer...')>]

    Getting a task by name:

       >>> task = service.MessageInABottle
       >>> task.url
       'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESR
I_Currents_World/GPServer/MessageInABottle/?f=json'
       >>> task.synchronous
       True
       >>> task.name
       'MessageInABottle'

    Inspecting tasks:

       >>> [(param['name'], param['dataType']) for param in task.parameters if p
aram['direction'] == 'esriGPParameterDirectionInput']
       [('Input_Point', 'GPFeatureRecordSetLayer'), ('Days', 'GPDouble')]

    Executing a job:

       >>> results = service.MessageInABottle(_server_admin.Point(-11, 38, _serv
er_admin.projections.geographic.GCS_WGS_1984), 2)
       >>> import time
       >>> while results.running:
       ...   time.sleep(0.25)
       ...
       >>> results.Output.features
       [{'geometry': MULTILINESTRING((-11.00000 38.00000,-10.85327 37.73851,-10.
83942 37.71683,-10.83734 37.71359,-10.83702 37.71310,-10.83697 37.71303)), 'attr
ibutes': {'shape_length': 0.330091748127675, 'fid': 1, 'fnode_': 0}}]

PACKAGE CONTENTS
    admin (package)
    geometry
    gptypes
    projections
    server
    utils

DATA
    USER_AGENT = 'Mozilla/4.0 (arcrest)'
    geographic = <_server_admin.projections.geographic object>
    projected = <_server_admin.projections.projected object>
Tags (2)
0 Kudos
2 Replies
TedCronin
MVP Honored Contributor
This looks pretty promising.  Can I start and stop services?  I assume that would be _server_admin.admin
0 Kudos
TedCronin
MVP Honored Contributor
or, I think it should be _server_admin.server
0 Kudos