arcgis.gis.server module

A collection of classes for administering an ArcGIS Enterprise server.

Server

class arcgis.gis.server.Server(url, gis=None, **kwargs)

Bases: arcgis.gis.server._common._base.BaseServer

An ArcGIS Enterprise Server site used for hosting GIS Web services.

Argument Description
url

Required string. The URL to the ArcGIS Server administration end point for the ArcGIS Server Site.

Example: https://gis.mysite.com/arcgis/admin

The URL should be formatted as follows: <scheme>://<fully_qualified_domain_name>:<port (optional)>/<web adaptor>/admin

Note: Using the fully-qualified domain name to the server, also known as the Web Context URL, is recommended as generally the SSL Certificate binding for the web server uses this hostname.

gis Optional string. The GIS object representing the Portal which thi Server is federated with. The GIS object should be logged in with a username in the publisher or administrator Role in order to administer the Server
Optional Argument Description
baseurl Optional string. The root URL to a site. Example: https://mysite.com/arcgis
tokenurl Optional string. Used when a site is federated or when the token URL differs from the site’s baseurl. If a site is federated, the token URL will return as the Portal token and ArcGIS Server users will not validate correctly.
username Optional string. The login username for BUILT-IN GIS Server security.
password Optional string. A secret word or phrase that must be used to gain access to the account above.
key_file Optional string. The path to a PKI key file used to authenticate the user to the Web Server in front of the ArcGIS Server site.
cert_file Optional string. The path to PKI cert file used to authenticate the user to the Web Server in front of the ArcGIS Server site.
proxy_host

Optional string. The web address to the proxy host if the environment where the Python API is running requires a proxy host for access to the Site URL or GIS URL.

Example: proxy.mysite.com

proxy_port Optional integer. The port which the proxy is accessed through, default is 80.
expiration Optional integer. This is the length of time in minutes that a token requested through this login process will be valid for. Example: 1440 is one day. The Default is 60.
all_ssl Optional boolean. If True, all calls will be made over HTTPS instead of HTTP. The default is False.
portal_connection Optional string. This is used when a site is federated. It is the ArcGIS Online or Portal GIS object used.
initialize Optional boolean. If True, the object will attempt to reach out to the URL resource and populate at creation time. The default is False.
content

Gets the Services Directory which can help you discover information about services available on a particular server. A service represents a local GIS resource whose functionality has been made available on the server to a wider audience. For example, an ArcGIS Server administrator can publish an ArcMap document (.mxd) as a map service. Developers and clients can display the map service and query its contents.

The Services Directory is available as part of the REST services infrastructure available with ArcGIS Server installations. It enables you to list the services available, including secured services when you provide a proper login. For each service, a set of general properties are displayed. For map services, these properties include the spatial extent, spatial reference (coordinate system) and supported operations. Layers are also listed, with links to details about layers, which includes layer fields and extent. The Services Directory can execute simple queries on layers.

The Services Directory is also useful for finding information about non-map service types. For example, you can use the Services Directory to determine the required address format for a geocode service, or the necessary model inputs for a geoprocessing service.

datastores

Gets the information about the data holdings of the server. Data items are used by ArcGIS for Desktop and other clients to validate data paths referenced by GIS services. You can register new data items with the server by using the Register Data Item operation. Use the Find Data Items operation to search through the hierarchy of data items. A relational data store type represents a database platform that has been registered for use on a portal’s hosting server by the ArcGIS Server administrator. Each relational data store type describes the properties ArcGIS Server requires in order to connect to an instance of a database for a particular platform. At least one registered relational data store type is required before client applications such as Insights for ArcGIS can create Relational Database Connection portal items. The Compute Ref Count operation counts and lists all references to a specific data item. This operation helps you determine if a particular data item can be safely deleted or refreshed.

logs

Gives users access the ArcGIS Server’s logs and lets administrators query and find errors and/or problems related to the server or a service.

Logs are the records written by the various components of ArcGIS Server. You can query the logs and change various log settings. Note ArcGIS Server Only

machines

Gets the list of server machines registered with the site. This resource represents a collection of all the server machines that have been registered with the site. It other words, it represents the total computing power of your site. A site will continue to run as long as there is one server machine online. For a server machine to start hosting GIS services, it must be grouped (or clustered). When you create a new site, a cluster called ‘default’ is created for you. The list of server machines in your site can be dynamic. You can register additional server machines when you need to increase the computing power of your site or unregister them if you no longer need them.

publish_sd(sd_file, folder=None)

Publishes a service definition file to ArcGIS Server.

Argument Description
sd_file Required string. The service definition file to be uploaded and published.
folder Optional string. The folder in which to publish the service definition file to. If this folder is not present, it will be created. The default is None in which case the service definition will be published to the System folder.
Returns:A boolean indicating success (True) or failure (False).
services

Gives the administrator access to the services on ArcGIS Server as a ServerManager Object.

site

Gets the site’s collection of server resources. This collection includes server machines that are installed with ArcGIS Server, including GIS services, data and so on. The site resource also lists the current version of the software. When you install ArcGIS Server on a server machine for the first time, you must create a new site. Subsequently, newer server machines can join your site and increase its computing power. Once a site is no longer required, you can delete the site, which will cause all of the resources to be cleaned up.

system

Provides access to common system configuration settings.

usage

Gets the collection of all the usage reports created within your site. The Create Usage Report operation lets you define a new usage report.

users

Gets operations to work with users.

ServicesDirectory

class arcgis.gis.server.catalog.ServicesDirectory(url, username=None, password=None, key_file=None, cert_file=None, verify_cert=False, **kwargs)

Bases: arcgis.gis.server._common._base.BaseServer

Provides ArcGIS Server Services Directory access.

The Services Directory allows you to browse the contents of an ArcGIS Server and obtain information that can be useful to endusers for developing applications, performing analysis, or cataloging services. The ServicesDirectory is a view of the ArcGIS Server REST API in a python class.

With the Services Directory, you can do the following:
  • Browse the contents of the GIS Server and get service-level metadata
  • Navigate a series of links to view information about the services on your GIS Server.
  • Get information to help you develop applications

When you develop applications with the Python API, you must provide URLs to services and the layers and functionality they expose. The Services Directory provides an interactive way for you to construct those URLs.

The Services Directory works using REST. REST is an architectural style that allows ArcGIS Server to reveal a hierarchy of information about itself through endpoints, or URLs. When you use the Services Directory, you navigate through a series of links to discover information about the server. Each time you click a link, you see a new page that reveals additional information about what’s available on the server. The information that you see on the page is retrieved through REST using the page’s URL.

Arguments Description
url

string required. The web address to the ArcGIS Server administration end point.

Example: https://mysite.com/arcgis

The URL should be formatted as follows: <scheme>://<host>:<port (optional)>/<web adapter>

baseurl optional string, the root URL to a site. Example: https://mysite.com/arcgis
tokenurl optional string. Used when a site if federated or when the token URL differs from the site’s baseurl. If a site is federated, the token URL will return as the Portal token and ArcGIS Server users will not validate correctly.
username optional string, login username for BUILT-IN security
password optional string, a secret word or phrase that must be used to gain access to the account above.
key_file optional string, path to PKI ket file
cert_file optional string, path to PKI cert file
proxy_host

optional string, web address to the proxy host

Example: proxy.mysite.com

proxy_port optional integer, default is 80. The port where the proxy resided on
expiration optional integer. The Default is 60. This is the length of time a token is valid for. Example 1440 is one week.
all_ssl optional boolean. The default is False. If True, all calls will be made over HTTPS instead of HTTP.
portal_connection optional GIS. This is used when a site is federated. It is the ArcGIS Online or Portal GIS object used.
initialize optional boolean. The default is False. If True, the object will attempt to reach out to the URL resource and populate at creation time.
verify_cert optional booean. The defaut is True. If False, any certificate errors will be ignored. This is useful for new sites or where site that have invalid certificates.
find(service_name, folder=None)

finds a service based on it’s name in a given folder

folders

returns a list of server folders

get(name, folder=None)

returns a single service in a folder

list(folder=None)

returns a list of services at the given folder

report(as_html=True, folder=None)

Generates a table of Services in the given folder, as a Pandas dataframe.

Service

class arcgis.gis.server.Service(url, gis, initialize=False, **kwargs)

Bases: arcgis.gis.server._common._base.BaseServer

Represents a GIS administrative service

(This should not be created by a user)

delete()

deletes a service from arcgis server

edit(service)

To edit a service, you need to submit the complete JSON representation of the service, which includes the updates to the service properties. Editing a service causes the service to be restarted with updated properties.

Argument Description
service Required dict. The service JSON as a dictionary.
Returns:boolean
extensions

lists the extensions on a service

rename(new_name)

Renames this service to the new name

Argument Description
new_name Required string. New name of the current service.
Returns:boolean
restart()

restarts the current service

start()

starts the specific service

statistics

returns the stats for the service

status

returns the status of the service

stop()

stops the current service

Machine

class arcgis.gis.server.Machine(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

A resource to provide administrative tools for managing this machine and the required SSL Certificate.

Note

The Machine

A server machine represents a machine on which ArcGIS Server software has been installed and licensed. A site is made up of one or more machines that must be registered with the site. The site’s machines work together to host GIS services and data, and provide administrative capabilities for the site. Each server machine is capable of performing all these administrative tasks and hence a site can be thought of as a distributed peer-to-peer network of machines. The server machine communicates with its peers over a range of TCP and UDP ports that can be configured using the edit operation (http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Edit_Machine/02r3000001st000000/ ).

Note

SSL Certificates

A certificate represents a key pair that has been digitally signed and acknowledged by a Certifying Authority (CA). It is the most fundamental component in enabling SSL on your server. Before you enable SSL on your server, you need to generate a certificate and get it signed by a trusted CA.

The Generate Certificate (http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Generate_Certificate/02r3000001tt000000/ ) operation creates a new self-signed certificate and adds it to the keystore. For your convenience, the server is capable of generating self-signed certificates that can be used during development or staging. However, it is critical that you obtain CA-signed certificates when standing up a production server. Even though a self-signed certificate can be used to enable SSL, it is recommended that you use these only on staging or development servers.

In order to get a certificate signed by a CA, you need to generate a CSR (certificate signing request) and then submit it to your CA. The CA will sign your certificate request which can then be imported into the server by using the import CA signed certificate operation.

delete_certificate(certificate)

Deletes a SSL certificate using the certificate alias.

Argument Description
certificate Required string. The name of the certificate to delete
Returns:boolean
export_certificate(certificate)

Downloads an SSL certificate. The file returned by the server is an X.509 certificate. The downloaded certificate can then be imported into a client that is making HTTP requests.

Argument Description
certificate Required string. The name of the certificate in the key store.
Returns:The SSL certificate object.
generate_CSR(certificate)

Generates a certificate signing request (CSR) for a self-signed certificate. A CSR is required by a CA to create a digitally signed version of your certificate. Supply the certificate object that was created with method ssl_certificate.

Argument Description
certificate Required string. The name of the certificate in the key store.
Returns:The CSR.
import_CA_signed_certificate(certificate, ca_signed_certificate)

Imports a certificate authority (CA)-signed SSL certificate into the key store.

Argument Description
certificate Required string. The name of the certificate in the key store.
ca_signed_certificate Required string. The multi-part POST parameter containing the signed certificate file.
Returns:A boolean indicating success (True) or failure (False).
import_existing_server_certificate(alias, cert_password, cert_file)

Imports an existing server certificate, stored in the PKCS #12 format, into the keystore. If the certificate is a CA-signed certificate, you must first import the CA root or intermediate certificate using the importRootCertificate operation.

Argument Description
alias Required string. A unique name for the certificate that easily identifies it.
cert_password Required string. The password to unlock the file containing the certificate.
cert_file Required string. The multi-part POST parameter containing the certificate file.
Returns:A boolean indicating success (True) or failure (False).
import_root_certificate(alias, root_CA_certificate)

Imports a certificate authority’s (CA) root and intermediate certificates into the keystore.

To create a production quality CA-signed certificate, you need to add the CA’s certificates into the keystore that enables the SSL mechanism to trust the CA (and the certificates it is signed). While most of the popular CA’s certificates are already available in the keystore, you can use this operation if you have a custom CA or specific intermediate certificates.

Argument Description
alias Required string. The name of the certificate.
root_CA_certificate Required string. The multi-part POST parameter containing the certificate file.
Returns:A boolean indicating success (True) or failure (False).
ssl_certificate(certificate)

Provides the self-signed certificate object.

Note

Even though a self-signed certificate can be used to enable SSL, it is recommended that you use a self-signed certificate only on staging or development servers.

Argument Description
certificate Required string. The name of the certificate in the key store to grab information from.
Returns:The certificate object.
ssl_certificates

Gets the list of all the certificates (self-signed and CA-signed) created for the server machine. The server securely stores these certificates inside a key store within the configuration store.

start()

Starts this server machine. Starting the machine enables its ability to host GIS services.

Returns:A boolean indicating success (True) or failure (False).
status

Gets the status/state of this machine.

stop()

Stops this server machine. Stopping the machine disables its ability to host GIS services.

Returns:A boolean indicating success (True) or failure (False).
unregister()

Removes this machine from the site. This server machine will no longer participate in the site or run any of the GIS services. All resources that were acquired by the server machine (memory, files, and so forth) will be released.

Typically, you should only invoke this operation if the machine is going to be shut down for extended periods of time, or if it is being upgraded.

Once a machine has been unregistered, you can create a new site or join an existing site.

Returns:A boolean indicating success (True) or failure (False).

Report

class arcgis.gis.server.Report(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

(This class should not be created by a user)

A utility class representing a single usage report returned by ArcGIS Server.

A Usage Report is used to obtain ArcGIS Server usage data for specified resources during a given time period. It specifies the parameters for obtaining server usage data, time range (parameters since, from_value, to_value), aggregation interval, and queries (which specify the metrics to be gathered for a collection of server resources, such as folders and services).

delete()

Deletes this usage report.

Returns:A JSON indicating success.
edit()

Edits the usage report. To edit a usage report, submit the complete JSON representation of the usage report which includes updates to the usage report properties. The name of the report cannot be changed when editing the usage report.

Values are changed in the class, to edit a property like metrics, pass in a new value.

Returns:A JSON indicating success.
query(query_filter=None)

Retrieves server usage data for this report. This operation aggregates and filters server usage statistics for the entire ArcGIS Server site. The report data is aggregated in a time slice, which is obtained by dividing up the time duration by the default (or specified) aggregationInterval parameter in the report. Each time slice is represented by a timestamp, which represents the ending period of that time slice.

In the JSON response, the queried data is returned for each metric- resource URI combination in a query. In the report-data section, the queried data is represented as an array of numerical values. A response of null indicates that data is not available or requests were not logged for that metric in the corresponding time-slice.

Argument Description
query_filter Optional string. The report data can be filtered by the machine where the data is generated. The filter accepts a comma-separated list of machine names; * represents all machines.
Returns:A JSON containing the server usage data.
USAGE EXAMPLE 1: Filters for the specified machines

{"machines": ["WIN-85VQ4T2LR5N", "WIN-239486728937"]}
USAGE EXAMPLE 2: No filtering, all machines are accepted

{"machines": "*"}

Datastore

class arcgis.gis.server.Datastore(datastore, path, datadict=None, **kwargs)

Bases: arcgis.gis.server._common._base.BaseServer

Represents a single Datastore in the Data Store Manager.

datasets

Gets the datasets in the data store (currently implemented for big data file shares).

delete()

Unregisters this data item from the data store.

Returns:A boolean indicating success (True) or failure (False).
hints

Gets the hints resource for a big data file share. Hints are advanced parameters to control the generation of a manifest.

manifest

Gets the manifest resource for a big data file share.

ref_count

The total number of references to this data item that exist on the server. You can use this property to determine if this data item can be safely deleted or taken down for maintenance.

Returns:A number indictaing the number of references to this data item.
update(item)

Edits this data item to update its connection information.

Argument Description
item Required string. The dict representation of the updated item.
Returns:True if the data item was successfully updated, False if the update failed.
validate()

Validates that this data item’s path (for file shares) or connection string (for databases) is accessible to every server node in the site. This is necessary for the data item to be registered and used successfully with the server’s data store.

Returns:True if the data item was successfully validated.

User

class arcgis.gis.server.User(usermanager, user_dict)

Bases: dict

A resource representing a user in the user store that can administer ArcGIS Server.

add_role(role_name)

Use this operation to assign roles to a user account when working with a user and role store that supports reads and writes. By assigning a role to a user, the user account automatically inherits all the role’s permissions.

Argument Description
role_name Required string. A role name to assign to this user.
Returns:A JSON indicating success.
delete()

Deletes this user account.

Returns:A JSON indicating success.
update(password=None, full_name=None, description=None, email=None)

Updates this user account in the user store.

Argument Description
password Optional string. The password for this user.
fullname Optional string. A full name for this user.
description Optional string. Provide comments or description for this user.
email Optional string. An email for this user account.
Returns:A JSON indicating success.

Role

class arcgis.gis.server.Role(rolemanager, roledict)

Bases: dict

Represents a single role on server.

delete()

Deletes this current role.

Returns:A boolean indicating success (True) or failure (False).
grant(username)

Adds a user to this role.

Parmeters Description
username Required string. The account name to add to the role.
Returns:A boolean indicating success (True) or failure (False).
set_privileges(privilage)

Assigns a privilege to this role.

Administrative access to ArcGIS Server is modeled as three broad tiers of privileges:

  • ADMINISTER - A role that possesses this privilege has unrestricted administrative access to ArcGIS Server.
  • PUBLISH - A role with PUBLISH privilege can only publish GIS services to ArcGIS Server.
  • ACCESS - No administrative access. A role with this privilege can only be granted permission to access one or more GIS services.

By assigning these privileges to one or more roles in the role store, ArcGIS Server’s security model supports role-based access control to its administrative functionality.

These privilege assignments are stored independent of ArcGIS Server’s role store. As a result, you don’t need to update your enterprise identity stores (like Active Directory).

Argument Description
privilage Required string. The capability to assign to the role. Choices are ADMINISTER, PUBLISH, ACCESS
Returns:A boolean indicating success (True) or failure (False).
update(description=None)

Updates this role in the role store with new information. This operation is available only when the role store is a read-write store such as the default ArcGIS Server store.

Argument Description
description Optional string. An optional field to add comments or a description for the role.
Returns:A status dictionary.

ServerManager

class arcgis.gis.server.ServerManager(gis)

Bases: object

Helper class for managing your ArcGIS Servers. This class is not created by users directly. An instance of this class, called ‘servers’, is available as a property of the gis.admin object. Administrators call methods on this ‘gis.admin.servers’ object to manage and interrogate ArcGIS Servers.

get(role=None, function=None)

Retrieves the ArcGIS Server(s) by role or function. While each argument is optional, at least one argument must be set with an allowed value other than None.

Argument Description
role Optional string. Limits the returned ArcGIS Servers based on the server’s role as either a hosting server for the portal, a federated server, or a server with restricted access to publishing. The allowed values are HOSTING_SERVER, FEDERATED_SERVER, or FEDERATED_SERVER_WITH_RESTRICTED_PUBLISHING, respectively.
function Optional string. Limits the returned ArcGIS Servers based on the server’s function. Provide a comma-separated list of values. The allowed values are GeoAnalytics, RasterAnalytics, and ImageHosting.
Returns:The ArcGIS Server(s) discovered that match the criteria.
list()

Retrieves all servers in a GIS.

Returns:A list of all servers found in the GIS.
update(server, role, function=None)

This operation allows you to set an ArcGIS Server federated with Portal for ArcGIS as the hosting server or to enforce fine-grained access control to a federated server. You can also remove hosting server status from an ArcGIS Server. To set a hosting server, an enterprise geodatabase must be registered as a managed database with the ArcGIS Server.

Argument Description
server Required string. The arcgis.gis.Server object.
role Required string. State whether the server is either a hosting server for the portal, a federated server, or a server with restricted access to publishing. The allowed values are HOSTING_SERVER, FEDERATED_SERVER, or FEDERATED_SERVER_WITH_RESTRICTED_PUBLISHING, respectively.
function Optional string. The specific function associated with this server. Provide a comma-separated list of values, but it is not recommend that a single server have all the server functions. The allowed values are GeoAnalytics, RasterAnalytics, and ImageHosting.
Returns:A status message of ‘success’ with the ID of the ArcGIS Server.
validate()

This operation returns information on the status of ArcGIS Servers registered with Portal for ArcGIS.

Returns:True if all servers are functioning as expected, False if there is an issue with 1 or more of the Federated Servers.

ServiceManager

class arcgis.gis.server.ServiceManager(url, gis, initialize=False, sm=None)

Bases: arcgis.gis.server._common._base.BaseServer

Helper class for managing services. This class is not created by users directly. An instance of this class, called ‘services’, is available as a property of the Server object. Users call methods on this ‘services’ object to managing services.

create_folder(folder_name, description='')

Creates a unique folder name on AGS

Argument Description
folder_name Required string. Name of the new folder.
description Optional string. Description of what the folder is.
Returns:boolean
create_service(service)

Creates a new GIS service in the folder. A service is created by submitting a JSON representation of the service to this operation.

The JSON representation of a service contains the following four sections:

  • Service Description Properties-Common properties that are shared
by all service types. Typically, they identify a specific service.
  • Service Framework Properties-Properties targeted towards the
framework that hosts the GIS service. They define the life cycle and load balancing of the service.
  • Service Type Properties -Properties targeted towards the core
service type as seen by the server administrator. Since these properties are associated with a server object, they vary across the service types. The Service Types section in the Help describes the supported properties for each service.
  • Extension Properties-Represent the extensions that are enabled
on the service. The Extension Types section in the Help describes the supported out-of-the-box extensions for each service type.
Argument Description
service Required dict. The service is the properties to create a service.
Returns:dict
Output:
dictionary status message
delete_folder(folder_name)

Removes a folder on ArcGIS Server

Argument Description
folder_name Required string. Name of the folder.
Returns:boolean
exists(folder_name, name=None, service_type=None)

This operation allows you to check whether a folder or a service exists. To test if a folder exists, supply only a folder_name. To test if a service exists in a root folder, supply both serviceName and service_type with folder_name=None. To test if a service exists in a folder, supply all three parameters.

Argument Description
folder_name Required string. The folder name to check for.
name Optional string. The service name to check for.
service_type
Optional string. A service type. Allowed values:
GeometryServer | ImageServer | MapServer | GeocodeServer | GeoDataServer | GPServer | GlobeServer | SearchServer
Returns:boolean
folders

returns a list of all folders

list(folder=None, refresh=True)

returns a list of services in the specified folder

Argument Description ————— ——————————————————————– folder Required string. The name of the folder to list services from. ————— ——————————————————————– refresh Optional boolean. Default is False. If True, the list of services will be

requested to the server, else the list will be returned from cache.
publish_sd(sd_file, folder=None)

publishes a service definition file to arcgis server

Argument Description
sd_file Required string. File path to the .sd file
folder Optional string. This parameter allows for the override of the folder option set in the SD file.
Returns:boolean

MachineManager

class arcgis.gis.server.MachineManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

This resource represents a collection of all the server machines that have been registered with the site. In other words, it represents the total computing power of your site. A site will continue to run as long as there is at least one server machine online.

For a server machine to start hosting GIS services, it must be in a cluster (note that clusters have been deprecated, see http://server.arcgis.com/en/server/latest/administer/windows/about-single-cluster-mode.htm ). When you create a new site, a cluster called ‘default’ (deployed with singleClusterMode set to true) is created for you.

The list of server machines in your site can be dynamic. You can register additional server machines when you need to increase the computing power of your site, or unregister them if you no longer need them.

get(machine_name)

Provides the machine object for a given machine.

Argument Description
machine_name Required string. The name of the server. Example: machines_obj.get(“SERVER.DOMAIN.COM”)
Returns:The machine object.
list()

Provides the list of machines in the cluster.

Returns:A JSON list of the machines in the cluster.
register(name, admin_url)

For a server machine to participate in a site, it needs to be registered with the site. The server machine must have ArcGIS Server software installed and authorized.

Registering machines this way is a “pull” approach to growing the site and is a convenient way when a large number of machines need to be added to a site. A server machine can also choose to join a site.

Argument Description
name Required string. The name of the server machine.
admin_url Required string. The URL where the Administrator API is running on the server machine. Example: http: //<machineName>:6080/arcgis/admin
Returns:A boolean indicating success (True) or failure (False).
rename(name, new_name)

You must use this operation if one of the registered machines has undergone a name change. This operation updates any references to the former machine configuration.

By default, when the server is restarted, it is capable of identifying a name change and repairing itself and all its references. This operation is a manual call to handle the machine name change.

Argument Description
name Required string. The former name of the server machine that is registered with the site.
new_name Required string. The new name of the server machine.
Returns:A boolean indicating success (True) or failure (False).

LogManager

class arcgis.gis.server.LogManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

Helper class for the management of logs by administrators.

Logs are the transaction records written by the various components of ArcGIS Server. You can query the logs, change various log settings, and check error messages for helping to determine the nature of an issue.

clean()

Deletes all the log files on all server machines in the site. This is an irreversible operation.

This operation forces the server to clean the logs, which has the effect of freeing up disk space. However, it is not required that you invoke this operation because the server periodically purges old logs.

Returns:A boolean indicating success (True) or failure (False).
count_error_reports(machine='*')

This operation counts the number of error reports (crash reports) that have been generated on each machine.

Argument Description
machine Optional string. The name of the machine on which to count the reports. The default will return the count for all machines in a site.
Returns:A dictionary with machine name and report count.
edit(level='WARNING', log_dir=None, max_age=90, max_report_count=10)

Provides log editing capabilities for the entire site.

Argument Description
level Optional string. The log level. Can be one of (in severity order): OFF, DEBUG, VERBOSE, FINE, INFO, WARNING, SEVERE. The default is WARNING.
log_dir Optional string. The file path to the root of the log directory.
max_age Optional integer. The number of days that a server should save a log file. The default is 90.
ax_report_count Optional integer. The maximum number of error report files per machine. The default is 10.
Returns:A JSON with the edited settings.
query(start_time=None, end_time=None, since_server_start=False, level='WARNING', services='*', machines='*', server='*', codes=None, process_IDs=None, export=False, export_type='CSV', out_path=None)

The query operation on the logs resource provides a way to aggregate, filter, and page through logs across the entire site.

Argument Description
start_time Optional string. The most recent time to query. Default is now. Time can be specified in milliseconds since UNIX epoch, or as an ArcGIS Server timestamp. For example { “startTime”: “2011-08-01T15:17:20,123”, … }, { “startTime”: 1312237040123, … }, respectively.
end_time Optional string. The oldest time to include in the result set. You can use this to limit the query to the last n minutes or hours as needed. Default is the beginning of all logging.
since_server_start Optional string. Gets only the records written since the server started (True). The default is False.
level Optional string. Gets only the records with a log level at or more severe than the level declared here. Can be one of (in severity order): DEBUG, VERBOSE, FINE, INFO, WARNING, SEVERE. The default is WARNING.
services Optional string. Query records related to a specific service. The default is all.
machines Optional string. Query records related to a specific machine. The default is all.
server Optional string. Query records related to a specific server. The default is all.
codes Optional string. Gets only the records with the specified code. The default is all. See http://server.arcgis.com/en/server/latest/administer/windows/log-codes-overview.htm
process_IDs Optional string. Query by the machine process ID that logged the event.
export Optional string. Boolean indicating whether to export the query results. The default is False (don’t export).
export_type Optional string. The export file type. CSV or TAB are the choices, CSV is the default.
out_path Optional string. The path to download the log file to.
Returns:A JSON of the log items that match the query. If export option is set to True, the output log file path is returned.
settings

Gets the current log settings.

ReportManager

class arcgis.gis.server.ReportManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

A utility class for managing usage reports for ArcGIS Server.

create(reportname, queries, metadata=None, since='LAST_DAY', from_value=None, to_value=None, aggregation_interval=None)

Creates a new usage report. A usage report is created by submitting a JSON representation of the usage report to this operation.

Argument Description
reportname Required string. The unique name of the report.
queries

Required string. A list of queries for which to generate the report. Specify the list as an array of JSON objects representing the queries. Each query specifies the list of metrics to be queried for a given set of resourceURIs.

The queries parameter has the following sub-parameters:

  • resourceURIs – Comma-separated list of resource URIs for which to report metrics. This specifies the services or folders for which to gather metrics. The resourceURI is formatted as below:

    • services/ – Entire Site

    • services/Folder/ – Folder within a Site. Reports metrics aggregated across all services within that Folder and Sub-Folders.

    • services/Folder/ServiceName.ServiceType – Service in a specified folder, for example:

      • services/Map_bv_999.MapServer
      • services/ServiceName.ServiceType
    • Service in the root folder, for example: Map_bv_999.MapServer.

metadata Optional string. Any JSON object representing presentation tier data for the usage report, such as report title, colors, line-styles, etc. Also used to denote visibility in ArcGIS Server Manager for reports created with the Administrator Directory. To make any report created in the Administrator Directory visible to Manager, include “managerReport”:true in the metadata JSON object. When this value is not set (default), reports are not visible in Manager. This behavior can be extended to any client that wants to interact with the Administrator Directory. Any user-created value will need to be processed by the client.
since

Optional string. The time duration of the report. The supported values are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM

  • LAST_DAY represents a time range spanning the previous 24 hours. This is the default value.
  • LAST_WEEK represents a time range spanning the previous 7 days.
  • LAST_MONTH represents a time range spanning the previous 30 days.
  • LAST_YEAR represents a time range spanning the previous 365 days.
  • CUSTOM represents a time range that is specified using the from and to parameters.
from_value Optional string. Only valid when since is CUSTOM. The timestamp (milliseconds since UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the beginning period of the report.
to_value Optional string. Only valid when since is CUSTOM. The timestamp (milliseconds since UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the ending period of the report.
aggregation_interval

Optional string. The aggregation interval in minutes. Server metrics are aggregated and returned for time slices aggregated using the specified aggregation interval. The time range for the report, specified using the since parameter (and from_value and to_value when since is CUSTOM) is split into multiple slices, each covering an aggregation interval. Server metrics are then aggregated for each time slice and returned as data points in the report data. When the aggregation_interval is not specified, the following defaults are used:

  • LAST_DAY: 30 minutes
  • LAST_WEEK: 4 hours
  • LAST_MONTH: 24 hours
  • LAST_YEAR: 1 week
  • CUSTOM: 30 minutes up to 1 day, 4 hours up to 1 week, 1

day up to 30 days, and 1 week for longer periods.

If the interval specified in Usage Reports Settings is more than the aggregationInterval, the interval is used instead.

Returns:A JSON indicating success.
USAGE EXAMPLE:

>>> queryObj = [{
    "resourceURIs": ["services/Map_bv_999.MapServer"],
    "metrics": ["RequestCount"]
    }]
>>> obj.createReport(
    reportname="SampleReport",
    queries=queryObj,
    metadata="This could be any String or JSON Object.",
    since="LAST_DAY"
    )
edit(interval, enabled=True, max_history=0)

Edits the usage reports settings that are applied to the entire site.

Argument Description
interval Required string. Defines the duration (in minutes) for which the usage statistics are aggregated or sampled, in-memory, before being written out to the statistics database.
enabled Optional string. When usage reports are enabled, service usage statistics are collected and persisted to a statistics database. When usage reports are disabled, the statistics are not collected. The default is True (enabled).
max_history Optional integer. The number of days after which usage statistics are deleted from the statistics database. If the max_history parameter is set to 0 (the default value), the statistics are persisted forever.
Returns:A JSON message indicating success.
list()

Retrieves a list of reports on the server.

Returns:A list of reports found.
quick_report(since='LAST_WEEK', queries='services/', metrics='RequestsFailed')

The operation quick_report generates an on the fly usage report for a service, services, or folder.

Argument Description
since

Optional string. The time duration of the report. The supported values are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM

  • LAST_DAY represents a time range spanning the previous 24 hours. This is the default value.
  • LAST_WEEK represents a time range spanning the previous 7 days.
  • LAST_MONTH represents a time range spanning the previous 30 days.
  • LAST_YEAR represents a time range spanning the previous 365 days.
  • CUSTOM represents a time range that is specified using the from and to parameters.
queries

Required string. A list of queries for which to generate the report. Specify the list as an array of JSON objects representing the queries. Each query specifies the list of metrics to be queried for a given set of resourceURIs.

The queries parameter has the following sub-parameters:

  • resourceURIs – Comma-separated list of resource URIs for which to report metrics. This specifies the services or folders for which to gather metrics. The resourceURI is formatted as below:

    • services/ – Entire Site

    • services/Folder/ – Folder within a Site. Reports metrics aggregated across all services within that Folder and Sub-Folders.

    • services/Folder/ServiceName.ServiceType – Service in a specified folder, for example:

      • services/Map_bv_999.MapServer
      • services/ServiceName.ServiceType
    • Service in the root folder, for example: Map_bv_999.MapServer.

metrics

Optional string. Comma separated list of metrics to be reported.

Supported metrics are:

  • RequestCount – the number of requests received
  • RequestsFailed – the number of requests that failed
  • RequestsTimedOut – the number of requests that timed out
  • RequestMaxResponseTime – the maximum response time
  • RequestAvgResponseTime – the average response time
  • ServiceActiveInstances – the maximum number of active (running) service instances sampled at 1 minute intervals, for a specified service
Returns:A Python dictionary of data on a successful query.
settings

Gets the current usage reports settings. The usage reports settings are applied to the entire site. When usage reports are enabled, service usage statistics are collected and persisted to a statistics database. When usage reports are disabled, the statistics are not collected. The interval parameter defines the duration (in minutes) during which the usage statistics are sampled or aggregated (in-memory) before being written out to the statistics database. Database entries are deleted after the interval specified in the max_history parameter ( in days), unless the max_history parameter is 0, for which the statistics are persisted forever.

DataStoreManager

class arcgis.gis.server.DataStoreManager(url, gis=None, **kwargs)

Bases: arcgis.gis.server._common._base.BaseServer

This resource provides information about the data holdings of the server, as well as the ability to manage (add new items, update primary data store, remove a data store item, etc) the data store. Data items are used by ArcGIS for Desktop and other clients to validate data paths referenced by GIS services.

Note

A relational data store type represents a database platform that has been registered for use on a portal’s hosting server by the ArcGIS Server administrator. Each relational data store type describes the properties ArcGIS Server requires in order to connect to an instance of a database for a particular platform. At least one registered relational data store type is required before client applications such as Insights for ArcGIS can create Relational Database Connection portal items.

Argument Description
url Required string. The URL to the Data Store URL.
gis Optional string. The GIS, Server, or ServicesDirectory object.
add(name, item)

Registers a new data item with the data store.

Argument Description
name Required string. The name of the new data item.
item Required string. The dictionary representing the data item. See http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000001s9000000
Returns:The data item if registered successfully, None otherwise.
add_bigdata(name, server_path=None, connection_type='fileShare')

Registers a bigdata fileshare with the data store.

Argument Description
name Required string. The unique bigdata fileshare name on the server.
server_path Optional string. The path to the folder from the server.
connection_type Optional string. Allows for the setting of the types of big data store. The value ‘fileShare’ is used for local big data stores, and for cloud stores, the connection_type should be ‘dataStore’. The value ‘fileShare’ is the default value.
Returns:The big data fileshare if registered successfully, None otherwise.
add_cloudstore(name, conn_str, object_store, provider, managed=False, folder=None)

Cloud Store data item represents a connection to a Amazon or Microsoft Azure store. Connection information for the data store item is stored within conn_str as a stringified JSON. ArcGIS Server encrypts connection string for storage. Connection strings that are encrypted will include a {crypt} prefix. You can get a data store item with decrypted connection string by passing a decrypt=true parameter in the request for a data store item. Data store with decrypted connection string will be returned only for requests made with https. The examples below show data stores with decrypted conn_str. A valid object_store (S3 bucket or Azure Blob store) is required. Folders within an object store are optional.

Argument Description
name Required string. The name of the cloud store.
conn_str Required string. The connection information for the cloud storage product.
object_store Required string. This is the amazon bucket path or Azuze path.
provider Required string. Values must be amazon or azure.
managed Optional boolean. When the data store is server only, the database is entirely managed and owned by the server and cannot be accessed by the publisher directly. When this option is chosen, the managed property should be set to true. Otherwise it is false.
folder Optional string. For some Azure cloud stores, an optional folder can be specified.
Returns:DataStore
add_database(name, conn_str, client_conn_str=None, conn_type='shared')

Registers a database with the data store.

Argument Description
name Required string. The unique database name on the server.
conn_str Required string. The path to the folder from the server (and client, if shared or serverOnly database)
client_conn_str Optional string. The connection string for client to connect to replicated enterprise database>
conn_type Optional string. The connection type. Default value is shared, other choices are replicated or serverOnly
Returns:The data item if successfully registered, None otherwise.
add_folder(name, server_path, client_path=None)

Registers a folder with the data store.

Argument Description
name Required string. The unique fileshare name on the server.
server_path Required string. The path to the folder from the server (and client, if shared path).
client_path Optional string. If folder is replicated, the path to the folder from the client; if folder is shared, don’t set this parameter.
Returns:The data item if successfully registered, None otherwise.
config

Gets the data store configuration properties. These properties affect the behavior of the data holdings of the server. For example, the blockDataCopy property - when this property is false, or not set at all, copying data to the site when publishing services from a client application is allowed. This is the default behavior. When this property is true, the client application is not allowed to copy data to the site when publishing. Rather, the publisher is required to register data items through which the service being published can reference data. Values: true | false

data_items

Gets the list of data items that are the root of all other data items in the data store.

generate_connection_string(sde)

Converts an SDE connection file to a string with encrypted password.

Parameters Description
sde required string. Path to SDE connection file.

returns: string on success, None on failure

Usage:

>>> con = dm.create_connection_string(r"c:\myfolder\postgres_db.sde")
>>> print(con)
'ENCRYPTED_PASSWORD=************************;SERVER=localhost;
INSTANCE=sde:postgresql:localhost,5432;DBCLIENT=postgresql;
DB_CONNECTION_PROPERTIES=localhost,5432;DATABASE=esri_spatial;
USER=sde;VERSION=sde.DEFAULT;AUTHENTICATION_MODE=DBMS'
get(path)

Retrieves the data item object at the given path.

Argument Description
path Required string. The path to the data item.
Returns:The data item object, None if not found.
get_relational_datastore_type(type_id)

This resource lists the properties of a registered relational data store of the given type. The properties returned are those that client applications must provide when creating a Relational Database Connection portal item.

Argument Description
type_id Required string. The datastore type ID of interest. See http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Relational_Data_Store_Types/02r300000303000000/
Returns:A JSON string listing the properties
get_total_refcount(path)

The total number of references to a given data item that exists on the server. You can use this operation to determine if a data resource can be safely deleted, or taken down for maintenance.

Argument Description
path Required string. The complete hierarchical path to the item.
Returns:A JSON dictionary containing a number representing the total count.
list()

Retrieves a list of datastore objects.

Returns:The list of datastore items.
make_datastore_machine_primary(item_name, machine_name)

Promotes a standby machine to the primary Data Store machine. The existing primary machine is downgraded to a standby machine.

Argument Description
item_name Required string. The primary machine item name in the data store.
machine_name Required string. The machine name of the machine to promote to primary.
Returns:A boolean indicating success (True) or failure (False).
make_primary(datastore_name, machine_name)

Promotes a standby machine to the primary Data Store machine. The existing primary machine is downgraded to a standby machine.

Argument Description
datastore_name Required string. The primary machine name in the data store.
machine_name Required string. The machine name of the machine to promote to primary.
Returns:A boolean indicating success (True) or failure (False).
relational_datastore_types

Gets a list of the relational data store types that have been registered with the server. Each registered relational data store type has both an id and a name property, as well as an array of userDefinedProperties, which indicates the properties client applications must provide when creating a Relational Database Connection portal item. Only administrators can register and unregister a relational data store type. The following database platforms are supported: SAP HANA, Microsoft SQL Server and Teradata.

remove_datastore_machine(item_name, machine_name)

Removes a standby machine from the Data Store. This operation is not supported on the primary Data Store machine.

Argument Description
item_name Required string. The standby machine item name in the data store.
machine_name Required string. The machine name of the machine to remove.
Returns:A boolean indicating success (True) or failure (False).
search(parent_path=None, ancestor_path=None, types=None, id=None)

Use this operation to search through the various data items that are registered in the server’s data store.

Argument Description
parent_path Optional string. The path of the parent under which to find items.
ancestor_path Optional string. The path of the ancestor under which to find items.
types Optional string. A filter for the type of the items (for example, fgdb or folder or egdb).
id Optional string. A filter to search by the ID of the item.
Returns:A JSON list of the items found matching the search criteria.
start(item_name, machine_name)

Starts the database instance running on the Data Store machine.

Argument Description
item_name Required string. The database item name in the data store to start.
machine_name Required string. The machine name of the machine with the database instance to start.
Returns:A boolean indicating success (True) or failure (False).
stop(item_name, machine_name)

Stop the database instance running on the Data Store machine.

Argument Description
item_name Required string. The database item name in the data store to stop.
machine_name Required string. The machine name of the machine with the database instance to stop.
Returns:A boolean indicating success (True) or failure (False).
validate()

Validates all the items in the data store.

Returns:True if all items are valid.
validate_egdb(data_store_name, name)

Checks the status of the given ArcGIS Data Store and provides a health check response.

Argument Description
data_store_name Required string. The item name of the data store.
name Required string. The machine name of where the data store is.
Returns:A JSON response containing general status information and an overall health report.

UserManager

class arcgis.gis.server.UserManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

This resource represents all users available in the user store that can administer ArcGIS Server and access the GIS services hosted on the server. As the user space could be potentially large, and there is not a listing of users, but you can use Get Users or Search operations to access their account information.

ArcGIS Server is capable of connecting to your enterprise identity stores such as Active Directory or other directory services exposed through the LDAP protocol. Such identity stores are treated as read only, and ArcGIS Server does not attempt to update them. As a result, operations that need to update the identity store (such as adding users, removing users, updating users, assigning roles and removing assigned roles) are not supported when identity stores are read only. On the other hand, you could configure your ArcGIS Server to use the default identity store (shipped with the server) which is treated as a read-write store.

The total number of users are returned in the response.

Note

Typically, this resource must be accessed over an HTTPS connection.

create(username, password, fullname=None, description=None, email=None)

Adds a user account to the user store.

Argument Description
username Required string. The name of the new user. The name must be unique in the user store.
password Optional string. The password for this user.
fullname Optional string. A full name for this user.
description Optional string. Provide comments or description for this user.
email Optional string. An email for this user account.
Returns:A JSON indicating success.
get(username)

Finds a specific user.

Argument Description
username Required string. The user to find.
Returns:The user object.
me

Gets the user object as the current logged in user. If the username cannot be found, for example, the site administrator account, then just the username is returned.

roles

Helper object to manage custom roles for users

search(username, max_results=25)

You can use this operation to search a specific user or a group of users from the user store. The size of the search result can be controlled with the max_results parameter.

Argument Description
username Required string. The user or users to find.
max_count Optional integer. The maximum number of users to return for this query. The default is 25.
Returns:A list of users found.

RoleManager

class arcgis.gis.server.RoleManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

This resource represents all roles available in the role store. The ArcGIS Server security model supports a role-based access control in which each role can be assigned certain permissions (privileges) to access one or more resources. Users are assigned to these roles. The server then authorizes each requesting user based on all the roles assigned to the user.

ArcGIS Server is capable of connecting to your enterprise identity stores such as Active Directory or other directory services exposed via the LDAP protocol. Such identity stores are treated as read-only stores and ArcGIS Server does not attempt to update them. As a result, operations that need to update the role store (such as adding roles, removing roles, updating roles) are not supported when the role store is read-only. On the other hand, you can configure your ArcGIS Server to use the default role store shipped with the server, which is treated as a read-write store.

all(start_index=0, page_size=10)

This operation gives you a pageable view of roles in the role store. It is intended for iterating through all available role accounts. To search for specific role accounts instead, use the Search Roles operation.

Argument Description
start_index Optional integer. The starting index (zero-based) from the roles list to be returned in the result page. The default is 0.
page_size Optional integer. The maximum number of roles to return in the result page. The default size is 10.
Returns:A JSON dictionary containing the list of roles found and a boolean on if there are more roles.
count

Gets the number of roles for ArcGIS Server.

create(name, description='')

Adds a role to the role store. This operation is available only when the role store is a read-write store such as the default ArcGIS Server store.

If the name of the role exists in the role store, an error will be returned.

Argument Description
name Required string. The name of the new role. The name must be unique in the role store.
description Optional string. Provide comments or description for the role.
Returns:A JSON message as dictionary
get_role(role_id=None, max_count=10)

Use this operation to search a specific role or a group of roles from the role store.

Argument Description
role_id Optional string. A filter string to search for the roles
max_count Optional integer. The maximum number of the result items that can be retuned. The default is 10.
Returns:A JSON message as dictionary.

SystemManager

class arcgis.gis.server.SystemManager(url, gis, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

The System resource is a collection of miscellaneous server-wide resources such as server properties, server directories, the configuration store, Web Adaptors, and licenses.

clear_cache()

This operation clears the cache on all REST handlers in the system. While the server typically manages the REST cache for you, use this operation to get explicit control over the cache.

Returns:A boolean indicating success (True).
configuration_store

Gets the ConfigurationStore object for this site.

deployment

Gets the load balancing value for this site. Load balancing is an ArcGIS Server deployment configuration resource that can control the load balancing functionality between GIS server machines. A value of True means that load balancing is disabled.

singleClusterMode - At 10.4, in large sites with a single cluster, the site is configured to prevent load balancing between GIS server machines. This reduces network traffic between machines in the site and helps reduce load on your network. Upgrades from earlier versions will set this property to true if the site uses a single cluster. Sites with multiple clusters cannot use singleClusterMode.

To prevent load balancing, the following criteria must be met:

  • All machines in the site must participate in a single cluster. Multiple clusters cannot exist.
  • An external load balancer or ArcGIS Web Adaptor must be configured to forward requests to the site. If no external gateway exists, requests will only be handled by the machine designated in the request.

To enable load balancing, set this property to false. Updating this property will restart all machines in the site.

directories()
Returns:The server directory object in a list.
handlers

Gets the handler of this server. A handler exposes the GIS capabilities of ArcGIS Server through a specific interface/API. There are two types of handlers currently available in the server:

  • Rest – Exposes the REST-ful API
  • Soap – Exposes the SOAP API

The Rest Handler resource exposes some of the administrative operations on the REST handler such as clearing the cache.

jobs

Gets the Jobs object.

licenses

Gets the license resource list. The licenses resource lists the current license level of ArcGIS for Server and all authorized extensions. Contact Esri Customer Service if you have questions about license levels or expiration properties.

platform_services

Provides access to the platform services that are associated with GeoAnalytics.

rest_handler

Gets a list of resources accessible throught the REST API.

server_properties

Gets the server properties for the site as an object.

unregister_webadaptor(wa_id)

Unregistering a Web Adaptor removes the Web Adaptor from the ArcGIS Server’s trusted list. The Web Adaptor can no longer submit requests to the server.

Argument Description
wa_id Required string. The web adaptor ID.
Returns:A boolean indicating success (True).
update_web_adaptor(wa_id, description, http_port, https_port)

This operation allows you to update the description, HTTP port, and HTTPS port of a Web Adaptor that is registered with the server.

Note

This operation is only meant to change the descriptive properties of the Web Adaptor and does not affect the configuration of the web server that deploys your Web Adaptor.

Argument Description
wa_id Required string. The web adaptor ID.
description Required string. A description of this web adaptor.
http_port Required integer. The HTTP port of the web server.
https_port Required integer. The HTTPS (SSL) port of the web server that runs the web adaptor.
Returns:A boolean indicating success (True), else a Python dictionary containing an error message.
update_web_adaptors_configuration(config)

You can use this operation to change the Web Adaptor configuration and the sharedkey attribute. The sharedkey attribute must be present in the request.

Argument Description
config Required string. The configuration items to be updated for this web adaptor. Always include the web adaptor’s sharedkey attribute.
Returns:A boolean indicating success (True), else a Python dictionary containing an error message.
web_adaptors

Gets a list of all the Web Adaptors that have been registered with the site. The server will trust all these Web Adaptors and will authorize calls from these servers.

To configure a new Web Adaptor with the server, you’ll need to use the configuration web page or the command line utility. For full instructions, see Configuring the Web Adaptor after installation.

web_adaptors_configuration

Gets the Web Adaptors configuration which is a resource of all the configuration parameters shared across all the Web Adaptors in the site. Most importantly, this resource lists the shared key that is used by all the Web Adaptors to encrypt key data bits for the incoming requests to the server.

SiteManager

class arcgis.gis.server.SiteManager(server, initialize=False)

Bases: object

A site is a collection of server resources. This collection includes server machines that are installed with ArcGIS Server, including GIS services, data and so on. The site resource also lists the current version of the software. When you install ArcGIS Server on a server machine for the first time, you must create a new site. Subsequently, newer server machines can join your site and increase its computing power. Once a site is no longer required, you can delete the site, which will cause all of the resources to be cleaned up.

Argument Description
server Required string. The arcgis.gis.server object.
static create(username, password, config_store_connection, directories, cluster=None, logs_settings=None, run_async=False, **kwargs)

This is the first operation that you must invoke when you install ArcGIS Server for the first time. Creating a new site involves:

-Allocating a store to save the site configuration -Configuring the server machine and registering it with the site -Creating a new cluster configuration that includes the server

machine

-Configuring server directories -Deploying the services that are marked to auto-deploy

Because of the sheer number of tasks, it usually takes some time for this operation to complete. Once a site has been created, you can publish GIS services and deploy them to your server machines.

Argument Description
connection  
url Required string. URI string to the site.
username Required string. The name of the administrative account to be used by the site. This can be changed at a later stage.
password Required string. The password to the administrative account.
configStoreConnection Required string. A JSON object representing the connection to the configuration store. By default, the configuration store will be maintained in the ArcGIS Server installation directory.
directories Required string. A JSON object representing a collection of server directories to create. By default, the server directories will be created locally.
cluster Optional string. An optional cluster configuration. By default, the site will create a cluster called ‘default’ with the first available port numbers starting from 4004.
logsSettings Optional string. Optional log settings, see http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Log_Settings/02r3000001t6000000/ .
runAsync Optional boolean. A flag to indicate if the operation needs to be run asynchronously.
Optional Argument Description
baseurl Optional string. The root URL to a site. Example: https://mysite.com/arcgis
tokenurl Optional string. Used when a site is federated or when the token URL differs from the site’s baseurl. If a site is federated, the token URL will return as the Portal token and ArcGIS Server users will not validate correctly.
username Optional string. The login username for BUILT-IN security.
password Optional string. A secret word or phrase that must be used to gain access to the account above.
key_file Optional string. The path to PKI key file.
cert_file Optional string. The path to PKI cert file.
proxy_host

Optional string. The web address to the proxy host.

Example: proxy.mysite.com

proxy_port Optional integer. The port where the proxy resides on, default is 80.
expiration Optional integer. This is the length of time a token is valid for. Example 1440 is one week. The Default is 60.
all_ssl Optional boolean. If True, all calls will be made over HTTPS instead of HTTP. The default is False.
portal_connection Optional string. This is used when a site is federated. It is the ArcGIS Online or Portal GIS object used.
initialize Optional boolean. If True, the object will attempt to reach out to the URL resource and populate at creation time. The default is False.
Returns:Success statement.
delete()

Deletes the site configuration and releases all server resources. This operation is well suited for development or test servers that need to be cleaned up regularly. It can also be performed prior to uninstall. Use caution with this option because it deletes all services, settings, and other configurations.

This operation performs the following tasks:

  • Stops all server machines participating in the site. This in turn stops all GIS services hosted on the server machines.
  • All services and cluster configurations are deleted.
  • All server machines are unregistered from the site.
  • All server machines are unregistered from the site.
  • The configuration store is deleted.

Note

This is an unrecoverable operation!

Returns:A status indicating success or failure.
export(location=None)

Exports the site configuration to a location you specify as input to this operation.

Argument Description
location Optional string. A path to a folder accessible to the server where the exported site configuration will be written. If a location is not specified, the server writes the exported site configuration file to directory owned by the server and returns a virtual path (an HTTP URL) to that location from where it can be downloaded.
Returns:A status indicating success (along with the folder location) or failure.
import_site(location)

This operation imports a site configuration into the currently running site. Importing a site means replacing all site configurations (including GIS services, security configurations, and so on) of the currently running site with those contained in the site configuration file you supply as input. The input site configuration file can be obtained through the exportSite operation.

This operation will restore all information included in the backup, as noted in exportSite. When it is complete, this operation returns a report as the response. You should review this report and fix any problems it lists to ensure your site is fully functioning again. The importSite operation lets you restore your site from a backup that you created using the exportSite operation.

Argument Description
location Required string. A file path to an exported configuration or an ID referencing the stored configuration on the server.
Returns:A status indicating success (along with site details) or failure.
join(admin_url, username, password)

The Join Site operation is used to connect a server machine to an existing site. This is considered a ‘push’ mechanism, in which a server machine pushes its configuration to the site. For the operation to be successful, you need to provide an account with administrative privileges to the site. When an attempt is made to join a site, the site validates the administrative credentials, then returns connection information about its configuration store back to the server machine. The server machine then uses the connection information to work with the configuration store. If this is the first server machine in your site, use the Create Site operation instead.

Argument Description
admin_url Required string. The site URL of the currently live site. This is typically the Administrator Directory URL of one of the server machines of a site.
username Required string. The name of an administrative account for the site.
password Required string. The password of the administrative account.
Returns:A status indicating success or failure.
properties

Gets the site properties.

public_key

Gets the public key.

upgrade(run_async=False)

This is the first operation that must be invoked during an ArcGIS Server upgrade. Once the new software version has been installed and the setup has completed, this operation will be available. A successful run of this operation will complete the upgrade of ArcGIS Server.

Note

If errors are returned with the upgrade operation, you must address the errors before you can continue. For example, if you encounter an error about an invalid license, you will need to re-authorize the software using a valid license and you may then retry this operation.

This operation is available only when a server machine is currently being upgraded. It will not be available after a successful upgrade of a server machine.

Argument Description
run_async Required string. A flag to indicate if the operation needs to be run asynchronously. The default value is False.
Returns:A status indicating success or failure.

DirectoryManager

class arcgis.gis.server.DirectoryManager(system)

Bases: object

A collection of all the server directories is listed under this resource.

You can add a new directory using the Register Directory operation. You can then configure GIS services to use one or more of these directories. If you no longer need the server directory, you must remove the directory by using the Unregister Directory operation.

add(name, physicalPath, directoryType, maxFileAge, cleanupMode='NONE', description=None)

Registers a new server directory. While registering the server directory, you can also specify the directory’s cleanup parameters.

Argument Description
name Required string. The name of the server directory.
physical_path Required string. The absolute physical path of the server directory.
directory_type Required string. The type of server directory.
max_age Required integer. The length of time a file in the directory needs to be kept before it is deleted.
cleanup_mode Optional string. Defines if files in the server directory needs to be cleaned up. The default is None.
description Optional string. An optional description for the server directory. The default is None.
Returns:A boolean indicating success (True).
all()

Provides a configuration of this server directory. Server directories are used by GIS services as a location to output items such as map images, tile caches, and geoprocessing results. In addition, some directories contain configurations that power the GIS services.

Returns:A dictionary of this server directory configuration properties.
edit_services_directory(allowedOrigins, arcgis_com_map, arcgis_com_map_text, jsapi_arcgis, jsapi_arcgis_css, jsapi_arcgis_css2, jsapi_arcgis_sdk, serviceDirEnabled)

Allows you to update the Services Directory configuration. You can do such thing as enable or disable the HTML view of ArcGIS REST API, or adjust the JavaScript and map viewer previews of services in the Services Directory so that they work with your own locally hosted JavaScript API and map viewer.

Argument Description
allowed_origins Required string. A comma-separated list of URLs of domains allowed to make requests. An asterisk (*) can be used to denote all domains.
arcgis_com_map Required string. URL of the map viewer application used for service previews. Defaults to the ArcGIS.com map viewer but could be used to point at your own Portal for ArcGIS map viewer.
arcgis_com_map_text Required string. The text to use for the preview link that opens the map viewer.
jsapi_arcgis Required string. The URL of the JavaScript API to use for service previews. Defaults to the online ArcGIS API for JavaScript, but could be pointed at your own locally-installed instance of the JavaScript API.
jsapi_arcgis_css Required string. The CSS file associated with the ArcGIS API for JavaScript. Defaults to the online Dojo tundra.css.
jsapi_arcgis_css2 Required string. An additional CSS file associated with the ArcGIS API for JavaScript. Defaults to the online esri.css.
jsapi_arcgis_sdk Required string. The URL of the ArcGIS API for JavaScript help.
service_dir_enabled Required string. Flag to enable/disable the HTML view of the services directory.
Returns:A boolean indicating success (True).
get(name)

Retrieves a single directory registered with ArcGIS Server.

Argument Description
name Required string. The name of the registered directory.
Returns:The directory object.
properties

returns the current service directory properties for the server.

Returns:dict

ConfigurationStore

class arcgis.gis.server.ConfigurationStore(url, connection, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

A utility class for managing the Configuration Store of this server.

edit(type_value, connection, move=True, run_async=False)

You can use this operation to update the configuration store. Typically, this operation is used to change the location of the configuration store.

When ArcGIS Server is installed, the default configuration store uses local paths. As the site grows (more server machines are added), the location of the store must be updated to use a shared file system path. On the other hand, if you know at the onset that your site will have two or more server machines, you can start from a shared path while creating a site and skip this step altogether.

Argument Description
type_value Required string. The type of the configuration store. Values: FILESYSTEM
gis Required string. A file path or connection URL to the physical location of the store.
move Optional string. A boolean to indicate if you want to move the content of the current store to the new store. The default True (move the content).
run_async Optional string. Determines if this operation must run asynchronously. The default is False (doesn not have to run asynchronously).
Returns:A boolean indicating success (True).
recover()

Recovers the Configuration Store of the site.

If the shared configuration store for a site is unavailable, a site in read-only mode will operate in a degraded capacity that allows access to the ArcGIS Server Administrator Directory. You can recover a site if the shared configuration store is permanently lost. The site must be in read-only mode, and the site configuration files must have been copied to the local repository when switching site modes. The recover operation will copy the configuration store from the local repository into the shared configuration store location. The copied local repository will be from the machine in the site where the recover operation is performed.

Returns:A boolean indicating success (True).

Jobs

class arcgis.gis.server.Jobs(url, connection, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

This resource is a collection of all the administrative jobs (asynchronous operations) created within your site. When operations that support asynchronous execution are run, the server creates a new job entry that can be queried for its current status and messages.

get(job_id)

A job represents the asynchronous execution of an operation. You can acquire progress information by periodically querying the job.

Argument Description
job_id Required string. The ID of the job.
Returns:A JSON dictionary containing progress information for the job ID.
jobs

Gets the job IDs.

ServerDirectory

class arcgis.gis.server.ServerDirectory(url, connection, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

Server directories are used by GIS services as a location to output items such as map images, tile caches, and geoprocessing results. In addition, some directories contain configurations that power the GIS services. In a Site with more than one server machine these directories must be available on network shares, accessible to every machine in the site.

The following directory types can be registered with the server:

  • Output – Stores various information generated by services, such as map images. Instances: One or more
  • Cache – Stores tile caches used by map, globe, and image services for rapid performance. Instances: One or more
  • Jobs – Stores results and other information from geoprocessing services. Instances: One or more
  • System – Stores files that are used internally by the GIS server. Instances: One

Server directories that contain output of various GIS services can be periodically cleaned to remove old unused files. By using the cleanup mode and maximum file age parameters, you control when when you would like the files in these directories to be cleaned.

All the output server directories are automatically virtualized (they can be accessed over a URL) for you through the ArcGIS Server REST API.

clean()

Cleans the content (files and folders) within the directory that have passed their expiration date. Every server directory has the max file age and cleanup mode parameter that govern when a file created inside is supposed to be cleaned up. The server directory cleaner automatically cleans up the content within server directories at regular intervals. However, you can explicitly clean the directory by invoking this operation.

Returns:A boolean indicating success (True).
edit(physical_path, cleanup_mode, max_age, description)

The server directory’s edit operation allows you to change the path and clean up properties of the directory. This operation updates the GIS service configurations (and points them to the new path) that are using this directory, causing them to restart. It is therefore recommended that any edit to the server directories be performed when the server is not under load.

This operation is mostly used when growing a single machine site to a multiple machine site configuration, which requires that the server directories and configuration store be put on a network-accessible file share.

Argument Description
physical_path Required string. The absolute physical path of the server directory.
cleanup_mode Optional string. Defines if files in the server directory needs to be cleaned up. The default is None.
max_age Required integer. The length of time a file in the directory needs to be kept before it is deleted.
description Optional string. An optional description for the server directory. The default is None.
Returns:A boolean indicating success (True).
recover()

Recovers the shared server directories of the site.

If the shared server directories for a site are unavailable, a site in read-only mode will operate in a degraded capacity that allows access to the ArcGIS Server Administrator Directory. You can recover a site if the shared server directories are permanently lost. The site must be in read-only mode, and the site configuration files must have been copied to the local repository when switching site modes. The recover operation will copy the server directories from the local repository into the shared server directories location. The copied local repository will be from the machine in the site where the recover operation is performed.

Returns:A boolean indicating success (True).
unregister()

Unregisters a server directory. Once a directory has been unregistered, it can no longer be referenced (used) from within a GIS service.

Returns:A boolean indicating success (True).

ServerProperties

class arcgis.gis.server.ServerProperties(url, connection, initialize=False)

Bases: arcgis.gis.server._common._base.BaseServer

The Server has configuration parameters that can govern some of its intricate behavior. This Server Properties resource is a container for such properties. These properties are available to all server objects and extensions through the server environment interface.

The properties include:

  • CacheSizeForSecureTileRequests – An integer that specifies the number of users whose token information will be cached. This increases the speed of tile retrieval for cached services. If not specified, the default cache size is 200,000. Both REST and SOAP services honor this property. You’ll need to manually restart ArcGIS Server in order for this change to take effect.

  • DisableAdminDirectoryCache – Disables browser caching of the Administrator Directory pages. The default is False. To disable browser caching, set this property to True.

  • disableIPLogging – When a possible cross-site request forgery (CSRF) attack is detected, the server logs a message containing the possible IP address of the attacker. If you do not want IP addresses listed in the logs, set this property to True. Also, HTTP request referrers are logged at FINE level by the REST and SOAP handlers unless this property is set to True.

  • javaExtsBeginPort – Specifies a start port of the port range used for debugging Java server object extensions. Example: 8000

  • javaExtsEndPort – Specifies an end port of the port range used for debugging Java server object extensions. Example: 8010

  • localTempFolder – Defines the local folder on a machine that can be used by GIS services and objects. If this property is not explicitly set, the services and objects will revert to using the system’s default temporary directory.

    Note

    If this property is used, you must create the temporary directory on every server machine in the site. Example: /tmp/arcgis.

  • messageFormat – Defines the transmission protocol supported by the services catalog in the server. Values:

    • esriServiceCatalogMessageFormatBin,
    • esriServiceCatalogMessageFormatSoap,
    • esriServiceCatalogMessageFormatSoapOrBin
  • messageVersion – Defines the version supported by the services catalog in the server. Example: esriArcGISVersion101

  • PushIdentityToDatabase – Propogates the credentials of the logged-in user to make connections to an Oracle database. This property is only supported for use with Oracle databases. Values: True | False

  • suspendDuration – Specifies the duration for which the ArcGIS service hosting processes should suspend at startup. This duration is specified in milliseconds. This is an optional property that takes effect when suspendServiceAtStartup is set to True. If unspecified and suspension of service at startup is requested, then the default suspend duration is 30 seconds. Example: 10000 (meaning 10 seconds)

  • suspendServiceAtStartup – Suspends the ArcGIS service hosting processes at startup. This will enable attaching to those processes and debugging code that runs early in the lifecycle of server extensions soon after they are instantiated. Values: True | False

  • uploadFileExtensionWhitelist – This specifies what files are allowed to be uploaded through the file upload API by identifying the allowable extensions. It is a list of comma-separated extensions without dots. If this property is not specified, a default list is used. This is the default list: soe, sd, sde, odc, csv, txt, zshp, kmz, and geodatabase.

    Note

    Updating this list overrides the default list completely. This means if you set this property to a subset of the default list then only those items in the subset will be accepted for upload. Example: sd, so, sde, odc.

  • uploadItemInfoFileExtensionWhitelist – This specifies what files are allowed to be uploaded through the service iteminfo upload API by identifying the allowable extensions. It should be a list of comma-separated extensions without dots. If this property is not specified, a default list is used. This is the default list: xml, img, png, gif, jpg, jpeg, bmp.

    Note

    This list overrides the default list completely. This means if you set this property to a subset of the default list then only those items in the subset will be accepted for upload. Example: png, svg, gif, jpg, tiff, bmp.

  • WebContextURL – Defines the web front end as seen by your users. Example: http://mycompany.com/gis

update(properties)

This operation allows you to update the server properties. See the ServerProperties class description for all possible properties.

Argument Description
properties Required string. A Python dictionary of server properties to be updated.
Returns:A boolean indicating success (True).