arcgis.gis module

The gis module provides an information model for GIS hosted within ArcGIS Online or ArcGIS Enterprise. This module provides functionality to manage (create, read, update and delete) GIS users, groups and content. This module is the most important and provides the entry point into the GIS.

GIS

class arcgis.gis.GIS(url=None, username=None, password=None, key_file=None, cert_file=None, verify_cert=True, set_active=True, client_id=None, profile=None, **kwargs)

A GIS is representative of a single ArcGIS Online organization or an ArcGIS Enterprise deployment. The GIS object provides helper objects to manage (search, create, retrieve) GIS resources such as content, users, and groups.

Additionally, the GIS object has properties to query its state, which is accessible using the properties attribute.

The GIS provides a mapping widget that can be used in the Jupyter Notebook environment for visualizing GIS content as well as the results of your analysis. To create a new map, call the map() method.

The constructor constructs a GIS object given a url and user credentials to ArcGIS Online or an ArcGIS Enterprise portal. User credentials can be passed in using username/password pair, or key_file/cert_file pair (in case of PKI). Supports built-in users, LDAP, PKI, Integrated Windows Authentication (using NTLM and Kerberos) and Anonymous access.

If no url is provided, ArcGIS Online is used. If username/password or key/cert files are not provided, the currently logged-in user’s credentials (IWA) or anonymous access is used.

Persisted profiles for the GIS can be created by giving the GIS authorization credentials and specifying a profile name. The profile stores all of the authorization credentials (except the password) in the user’s home directory in an unencrypted config file named .arcgisprofile. The profile securely stores the password in an O.S. specific password manager through the keyring python module. (Note: Linux systems may need additional software installed and configured for proper security) Once a profile has been saved, passing the profile parameter by itself uses the authorization credentials saved in the configuration file/password manager by that profile name. Multiple profiles can be created and used in parallel.

See https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/ for examples.

Argument

Description

url

Optional string. If URL is None, then the URL will be ArcGIS Online. This should be a web address to either an ArcGIS Enterprise portal or to ArcGIS Online in the form: <scheme>://<fully_qualified_domain_name>/<web_adaptor> (ArcGIS Enterprise example) https://gis.example.com/portal

username

Optional string. The login user name (case-sensitive).

password

Optional string. If a username is provided, a password is expected. This is case-sensitive. If the password is not provided, the user is prompted in the interactive dialog.

key_file

Optional string. The file path to a user’s key certificate for PKI authentication

cert_file

Optional string. The file path to a user’s certificate file for PKI authentication. If a PFX or P12 certificate is used, a password is required. If a PEM file is used, the key_file is required.

verify_cert

Optional boolean. If a site has an invalid SSL certificate or is being accessed via the IP or hostname instead of the name on the certificate, set this value to False. This will ensure that all SSL certificate issues are ignored. The default is True. Warning Setting the value to False can be a security risk.

set_active

Optional boolean. The default is True. If True, the GIS object will be used as the default GIS object throughout the whole scripting session.

client_id

Optional string. Used for OAuth authentication. This is the client ID value.

profile

Optional string. the name of the profile that the user wishes to use to authenticate, if set, the identified profile will be used to login to the specified GIS.

In addition to explicitly named parameters, the GIS object supports optional key word arguments:

kwargs

Description

proxy_host

Optional string. The host name of the proxy server used to allow HTTP/S access in the network where the script is run.

ex: 127.0.0.1

proxy_port

Optional integer. The proxy host port. The default is 80.

token

Optional string. This is the Enterprise token for built-in logins. This parameter is only honored if the username/password is None and the security for the site uses BUILT-IN security.

api_key

Optional string. This is a key generated by the developer site to allow for a limited subset of the REST API functionality.

trust_env

Optional Boolean. Trust environment settings for proxy configuration, default authentication and similar. If False the GIS class will ignore the netrc files defined on the system.

# Usage Example 1: Anonymous Login to ArcGIS Online

gis = GIS()
# Usage Example 2: Built-in Login to ArcGIS Online

gis = GIS(username="someuser", password="secret1234")
# Usage Example 3: Built-in Login to ArcGIS Enterprise

gis = GIS(url="http://pythonplayground.esri.com/portal",
      username="user1", password="password1")
# Usage Example 4: Built-in Login to ArcGIS Enterprise, ignoring SSL errors

gis = GIS(url="http://pythonplayground.esri.com/portal", username="user1",
          password="password1", verify_cert=False)
# Usage Example 5: Anonymous ArcGIS Online Login with Proxy

gis = GIS(proxy_host='127.0.0.1', proxy_port=8888)
# Usage Example 6: PKI Login to ArcGIS Enterprise, using PKCS12 user certificate

gis = GIS(url="https://pkienterprise.esri.com/portal",
          cert_file="C:\users\someuser\mycert.pfx", password="password1")
property api_keys

Returns the APIKeyManager which allows User to generate, manage and modify API Keys for controlled application access.

The API Key manager is only available for ArcGIS Online

Returns

APIKeyManager

property content

The resource manager for GIS content. See ContentManager.

property datastore

The resource managers for GIS datastores. This is only available with ArcGIS Enterprise 10.7+. See PortalDataStore for more information.

Returns

PortalDataStore

property groups

The resource manager for GIS groups. See GroupManager.

property hub

The resource manager for GIS hub. See Hub.

map(location=None, zoomlevel=None, mode='2D', geocoder=None)

Creates a map widget centered at the declared location with the specified zoom level. If an address is provided, it is geocoded using the GIS’s configured geocoders and if a match is found, the geographic extent of the matched address is used as the map extent. If a zoomlevel is also provided, the map is centered at the matched address instead and the map is zoomed to the specified zoomlevel. See MapView for more information.

Note: The map widget is only supported within a Jupyter Notebook.

Argument

Description

location

Optional string. The address or lat-long tuple of where the map is to be centered.

zoomlevel

Optional integer. The desired zoom level.

mode

Optional string of either ‘2D’ or ‘3D’ to specify map mode. Defaults to ‘2D’.

geocoder

Optional Geocoder. Allows users to specify a geocoder to find a given location.

Returns

The map widget (displayed in Jupyter Notebook when queried).

Note

Note: If the Jupyter Notebook server is running over http, you need to configure your ArcGIS Enterprise portal or ArcGIS Online organization to allow your host and port; or else you will run into CORS issues when displaying this map widget.

This can be accomplished by signing into your ArcGIS Enterprise portal or ArcGIS Online organization in a browser, then navigating to:

Organization > Settings > Security > Allow origins > Add > http://localhost:8888 (replace with the host/port you are running on)

property org_settings

The portal settings resource is used to return a view of the portal’s configuration as seen by the current users, either anonymous or logged in. Information returned by this resource includes helper services, allowed redirect URIs, and the current configuration for any access notices or information banners.

Parameters

Description

settings

Required Dict. A dictionary of the settings

Fields

Description

anonymousAccessNotice

Dict. A JSON object representing a notice that is shown to your organization’s anonymous users. Ex: {‘title’: ‘Anonymous Access Notice Title’, ‘text’: ‘Anonymous Access Notice Text’, ‘buttons’: ‘acceptAndDecline’, ‘enabled’: True}

authenticatedAccessNotice

Dict. A JSON object representing a notice that is shown to your organization’s authenticated users. Ex: {‘title’: ‘Authenticated Access Notice Title’, ‘text’: ‘Authenticated Access Notice Text’, ‘buttons’: ‘okOnly’, ‘enabled’: True}

informationalBanner

Dict. A JSON object representing the informational banner that is shown at the top of your organization’s page. Ex: {‘text’: ‘Header Text’, ‘bgColor’: ‘grey’, ‘fontColor’: ‘blue’, ‘enabled’: True}

clearEmptyFields

Bool. If True, any empty dictionary will be set to null.

Returns

Dictionary

property properties

The properties of the GIS.

update_properties(properties_dict)

Updates the GIS’s properties from those in properties_dict. This method can be useful for updating the utility services used by the GIS.

Argument

Description

properties_dict

Required dictionary. A dictionary of just those properties and values that are to be updated.

Returns

True if successfully updated, False if unsuccessful.

Note

For examples of the property names and key/values to use when updating utility services, refer to the Portal parameters section at https://developers.arcgis.com/rest/users-groups-and-items/common-parameters.htm

# Usage Example: Update the geocode service

gis = GIS(profile='xyz')
upd = {'geocodeService': [{
  "singleLineFieldName": "Single Line Input",
  "name": "AtlantaLocator",
  "url": "https://some.server.com/server/rest/services/GeoAnalytics/AtlantaLocator/GeocodeServer",
  "itemId": "abc6e1fc691542938917893c8944606d",
  "placeholder": "",
  "placefinding": "true",
  "batch": "true",
  "zoomScale": 10000}]}

gis.update_properties(upd)
property url

Readonly URL of the GIS you are connected to.

property users

The resource manager for GIS users. See UserManager.

property version

returns the GIS version number

Item

class arcgis.gis.Item(gis, itemid, itemdict=None)

Bases: dict

An item (a unit of content) in the GIS. Each item has a unique identifier and a well known URL that is independent of the user owning the item. An item can have associated binary or textual data that’s available via the item data resource. For example, an item of type Map Package returns the actual bits corresponding to the map package via the item data resource.

Items that have layers (eg FeatureLayerCollection items and ImageryLayer items) and tables have the dynamic layers and tables properties to get to the individual layers/tables in this item.

add_comment(comment)

Adds a comment to an item. Available only to authenticated users who have access to the item.

Argument

Description

comment

Required string. Text to be added as a comment to a specific item.

Returns

Comment ID if successful, None on failure.

add_relationship(rel_item, rel_type)

Adds a relationship from this item to rel_item.

Note

Relationships are not tied to an item. They are directional links from an origin item to a destination item and have a type. The type defines the valid origin and destination item types as well as some rules. See Relationship types in REST API help for more information. Users don’t have to own the items they relate unless so defined by the rules of the relationship type.

Users can only delete relationships they create.

Relationships are deleted automatically if one of the two items is deleted.

Argument

Description

rel_item

Required Item object corresponding to the related item.

rel_type

Required string. The type of the related item; is one of [‘Map2Service’, ‘WMA2Code’, ‘Map2FeatureCollection’, ‘MobileApp2Code’, ‘Service2Data’, ‘Service2Service’]. See Relationship Types. in the REST API help for more information on this parameter.

Returns

Returns True if the relationship was added, False if the add failed.

property app_info

If the parent item is registered using the register app operation, this resource returns information pertaining to the registered app. Every registered app gets an App ID and App Secret which in OAuth speak are known as client_id and client_secret respectively.

Returns

dict

property comments

Gets a list of comments for a given item.

property content_status

The content_status property states if an Item is authoritative or deprecated. This givens owners and administrators of Item the ability to warn users that they should be either this information or not.

Argument

Description

value

Optional string or None. Defines if an Item is deprecated or authoritative. If a value of None is given, then the value will be reset.

Allowed Values: authoritative, deprecated, or None

copy(title=None, tags=None, snippet=None, description=None, layers=None)

Copy allows for the creation of an item that is derived from the current item.

For layers, copy will create a new item that uses the URL as a reference. For non-layer based items, these will be copied and the exact same data will be provided.

If title, tags, snippet of description is not provided the values from item will be used.

Copy use example:

  • Vector tile service sprite customization

  • Limiting feature service exposure

  • Sharing content by reference with groups

  • Creating backup items.

Usage Example

>>> item.copy()
<Item title:"gisslideshow - Copy 94452b" type:Microsoft Powerpoint owner:geoguy>
>>> item.copy(title="GIS_Tutorial")
<Item title:"GIS_Tutorial" type:Microsoft Powerpoint owner:geoguy>
>>> item.copy()
<Item title:"NZTiles - Copy 021a06" type:Vector Tile Layer owner:geoguy>

Argument

Description

title

Optional string. The name of the new item.

tags

Optional list of string. Descriptive words that help in the searching and locating of the published information.

snippet

Optional string. A brief summary of the information being published.

description

Optional string. A long description of the Item being published.

layers

Optional list of integers. If you have a layer with multiple and you only want specific layers, an index can be provided those layers. If nothing is provided, all layers will be visible.

Example: layers=[0,3] Example 2: layers=[9]

Returns

Item

copy_feature_layer_collection(service_name, layers=None, tables=None, folder=None, description=None, snippet=None, owner=None)

This operation allows users to copy existing Feature Layer Collections and select the layers/tables that the user wants in the service.

Argument

Description

service_name

Required string. It is the name of the service.

layers

Optional list/string. This is a either a list of integers or a comma seperated list of integers as a string. Each index value represents a layer in the feature layer collection.

tables

Optional list/string. This is a either a list of integers or a comma seperated list of integers as a string. Each index value represents a table in the feature layer collection.

folder

Optional string. This is the name of the folder to place in. The default is None, which means the root folder.

description

Optional string. This is the Item description of the service.

snippet

Optional string. This is the Item’s snippet of the service. It is no longer than 250 characters.

owner

Optional string/User. The default is the current user, but if you want the service to be owned by another user, pass in this value.

Returns

Item on success. None on failure

copy_item(*, title=None, tags=None, folder=None, include_resources=False, include_private=False)

The copy item operation creates a new item that is a copy of the original item on the server side.

Copy operation is allowed for the following:

  • Original item being copied is owned by the user invoking the copy operation.

  • User is an administrator.

  • User has itemControl update capability.

The new item created by the copy operation will have system generated itemID.

Hosted services are copied as reference only. Reserved keywords, ratings, views, comments and listing properties are reset for the new item.

Sharing access of the original item is not preserved. Sharing access of new item is set to private.

Relationships and dependencies of the original item are not maintained in the new item.

This method is only available on ArcGIS Online

Argument

Description

title

Optional string. The title of the destination item. If not specified, title of the original item is used.

tags

Optional String. New set of tags (comma separated) of the destination item.

folder

Optional String. Folder Id of the destination item. If the folder Id is not specified, then the item remains in the same folder.

If the administrator invokes a copy of an item belonging to another user, and does not specify the folder Id, the item gets created in the root folder of the administrator.

include_resources

Optional boolean. If true, the file resources of the original item will be copied over to the new item. Private file resources will not be copied over. If false, the file resources of the original item will not be copied over to the new item. The default is false.

include_private

If true, and if include_resources is set to true as well, then the private resources of the original item will be copied over to the new item. If false, the private file resources of the original item will not be copied over to the new item. The default is false.

Returns

Item

create_thumbnail(update=True)

Creates a Thumbnail for a feature service portal item using the service’s symbology and the print service registered for the enterprise.

Argument

Description

update

Optional boolean. When set to True, the item will be updated with the thumbnail generated in this call, else it will not update the item. The default is True.

Returns

DataFile

create_tile_service(title, min_scale, max_scale, cache_info=None, build_cache=False)

Allows publishers and administrators to publish hosted feature layers and hosted feature layer views as a tile service.

Argument

Description

title

Required string. The name of the new service. Example: “SeasideHeightsNJTiles”

min_scale

Required float. The smallest scale at which to view data. Example: 577790.0

max_scale

Required float. The largest scale at which to view data. Example: 80000.0

cache_info

Optional dictionary. If not none, administrator provides the tile cache info for the service. The default is the ArcGIS Online scheme.

build_cache

Optional boolean. Default is False; if True, the cache will be built at publishing time. This will increase the time it takes to publish the service.

Returns

The item if successfully added, None if unsuccessful.

delete(force=False, dry_run=False)

Deletes the item. If unable to delete, raises a RuntimeException. To know if you can safely delete the item, use the optional parameter ‘dry_run’

Argument

Description

force

Optional bool. Available in ArcGIS Enterprise 10.6.1 and higher. Force deletion is applicable only to items that were orphaned when a server federated to the ArcGIS Enterprise was removed accidentally before properly unfederating it. When called on other items, it has no effect.

dry_run

Optional bool. Available in ArcGIS Enterprise 10.6.1 and higher.If True, checks if the item can be safely deleted and gives you back either a dictionary with details. If dependent items are preventing deletion, a list of such Item objects are provided.

Returns

A bool containing True (for success) or False (for failure). When dry_run is used, a dictionary with details is returned.

USAGE EXAMPLE: Successful deletion of an item

item1 = gis.content.get('itemId12345')
item1.delete()

>> True
USAGE EXAMPLE: Failed deletion of an item

item1 = gis.content.get('itemId12345')
item1.delete()

>> RuntimeError: Unable to delete item. This service item has a related Service item
>> (Error Code: 400)
USAGE EXAMPLE: Dry run to check deletion of an item

item1 = gis.content.get('itemId12345abcde')
item1.delete(dry_run=True)

>> {'can_delete': False,
>> 'details': {'code': 400,
>> 'message': 'Unable to delete item. This service item has a related Service item',
>> 'offending_items': [<Item title:"Chicago_accidents_WFS" type:WFS owner:sharing1>]}}

Note

During the dry run, if you receive a list of offending items, attempt to delete them first before deleting the current item. You can in turn call ‘dry_run’ on those items to ensure they can be deleted safely.

delete_rating()

Removes the rating the calling user added for the specified item.

delete_relationship(rel_item, rel_type)

Deletes a relationship between this item and the rel_item.

Argument

Description

rel_item

Required Item object corresponding to the related item.

rel_type

Required string. The type of the related item; is one of [‘Map2Service’, ‘WMA2Code’, ‘Map2FeatureCollection’, ‘MobileApp2Code’, ‘Service2Data’, ‘Service2Service’]. See Relationship Types. in the REST API help for more information on this parameter.

Returns

Returns True if the relationship was deleted, False if the deletion failed.

property dependencies

returns a class to management Item dependencies

dependent_to()

Returns items, urls, etc that are dependent to this item. This capability (item dependencies) is not yet available on ArcGIS Online. Currently it is available only with an ArcGIS Enterprise.

dependent_upon()

Returns items, urls, etc that this item is dependent on. This capability (item dependencies) is not yet available on ArcGIS Online. Currently it is available only with an ArcGIS Enterprise.

download(save_path=None, file_name=None)

Downloads the data to the specified folder or a temporary folder if a folder is not provided.

Argument

Description

save_path

Optional string. Folder location to download the file to.

file_name

Optional string. The name of the file.

Returns

The download path if data was available, otherwise None.

download_metadata(save_folder=None)

Downloads the item metadata for the specified item id. Items with metadata have ‘Metadata’ in their typeKeywords.

Argument

Description

save_folder

Optional string. Folder location to download the item’s metadata to.

Returns

For a successful download of metadata, a file path. None if the item does not have metadata.

download_thumbnail(save_folder=None)

Downloads the thumbnail for this item.

Argument

Description

save_folder

Optional string. Folder location to download the item’s thumbnail to.

Returns

For a successful download of the thumbnail, a file path. None if the item does not have a thumbnail.

export(title, export_format, parameters=None, wait=True, enforce_fld_vis=None, tags=None, snippet=None, overwrite=False)

Exports a service item to the specified export format. Available only to users with an organizational subscription. Invokable only by the service item owner or an administrator, unless a Location Tracking Service or Location Tracking View. This is useful for long running exports that could hold up a script.

Argument

Description

title

Required string. The desired name of the exported service item.

export_format

Required string. The format to export the data to. Allowed types: ‘Shapefile’, ‘CSV’, ‘File Geodatabase’, ‘Feature Collection’, ‘GeoJson’, ‘Scene Package’, ‘KML’,

‘Excel’, ‘geoPackage’, or ‘Vector Tile Package’.

parameters

Optional string. A JSON object describing the layers to be exported and the export parameters for each layer. See https://developers.arcgis.com/rest/users-groups-and-items/export-item.htm for guidance.

wait

Optional boolean. Default is True, which forces a wait for the export to complete; use False for when it is okay to proceed while the export continues to completion.

enforce_fld_vis

Optional boolean. Be default when you are the owner of an item and the export operation is called, the data provides all the columns. If the export is being perform on a view, to ensure the view’s column definition is honor, then set the value to True. When the owner of the service and the value is set to False, all data and columns will be exported.

tags

Optional String. A comma seperated value of item descriptors.

snippet

Optional String. A short descriptive piece of text.

overwrite

Optional Boolean. If the export Item exists, the item will be replaced with the new one.

Returns

Item or dictionary. Item is returned when wait=True. A dictionary describing the status of the item is returned when wait=False.

get_data(try_json=True)

Retrieves the data associated with an item. Note that this call may return different results for different item types: some item types may even return None. See this REST API page for more information.

Argument

Description

try_json

Optional string. Default is True. For JSON/text files, if try_json is True, the method tries to convert the data to a Python dictionary (use json.dumps(data) to convert the dictionary to a string), otherwise the data is returned as a string.

Returns

Dependent on the content type of the data. For non-JSON/text data, binary files are returned and the path to the downloaded file. For JSON/text files, a Python dictionary or a string. All others will be a byte array, that can be converted to string using data.decode(‘utf-8’). Zero byte files will return None.

get_thumbnail()

Retrieves the bytes that make up the thumbnail for this item.

Returns

Bytes that represent the item.

Example

response = item.get_thumbnail()
f = open(filename, 'wb')
f.write(response)

URL to the thumbnail image.

property homepage

Gets the URL to the HTML page for the item.

property metadata

Gets and sets the item metadata for the specified item. Returns None if the item does not have metadata. Items with metadata have ‘Metadata’ in their typeKeywords.

move(folder, owner=None)

Moves this item to the folder with the given name.

Argument

Description

folder

Required string. The name of the folder to move the item to. Use ‘/’ for the root folder. For other folders, pass in the folder name as a string, or a dictionary containing the folder ID, such as the dictionary obtained from the folders property.

owner

Optional string or Owner object. The name of the user to move to.

Returns

A json object like the following: {“success”: true | false,

”itemId”: “<item id>”, “owner”: “<owner username>”, “folder”: “<folder id>”}

protect(enable=True)

Enables or disables delete protection on this item.

Argument

Description

enable

Optional boolean. Default is True which enables delete protection, False to disable delete protection.

Returns

A json object like the following: {“success”: true | false}

property proxies

Gets the ArcGIS Online hosted proxy services set on a registered app item with the Registered App type keyword. This resource is only available to the item owner and the organization administrator.

publish(publish_parameters=None, address_fields=None, output_type=None, overwrite=False, file_type=None, build_initial_cache=False, item_id=None)

Publishes a hosted service based on an existing source item (this item). Publishers can create feature, tiled map, vector tile and scene services.

Feature services can be created using input files of type csv, shapefile, serviceDefinition, featureCollection, and fileGeodatabase. CSV files that contain location fields (i.e. address fields or XY fields) are spatially enabled during the process of publishing. Shapefiles and file geodatabases should be packaged as *.zip files.

Tiled map services can be created from service definition (*.sd) files, tile packages, and existing feature services.

Vector tile services can be created from vector tile package (*.vtpk) files.

Scene services can be created from scene layer package (*.spk, *.slpk) files.

Service definitions are authored in ArcGIS Pro or ArcGIS Desktop and contain both the cartographic definition for a map as well as its packaged data together with the definition of the geo-service to be created.

Note

ArcGIS does not permit overwriting if you published multiple hosted feature layers from the same data item.

Argument

Description

publish_parameters

Optional dictionary. containing publish instructions and customizations. Cannot be combined with overwrite. See https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm for details.

address_fields

Optional dictionary. containing mapping of df columns to address fields, eg: { “CountryCode” : “Country”} or { “Address” : “Address” }

output_type

Optional string. Only used when a feature service is published as a tile service. eg: output_type=’Tiles’

overwrite

Optional boolean. If True, the hosted feature service is overwritten. Only available in ArcGIS Enterprise 10.5+ and ArcGIS Online.

file_type

Optional string. Some formats are not automatically detected, when this occurs, the file_type can be specified: serviceDefinition,shapefile,csv, tilePackage, featureService, featureCollection, fileGeodatabase, geojson, scenepackage, vectortilepackage, imageCollection, mapService, and sqliteGeodatabase are valid entries. This is an optional parameter.

build_initial_cache

Optional boolean. The boolean value (default False), if true and applicable for the file_type, the value will built cache for the service.

item_id

Optional string. Available in ArcGIS Enterprise 10.8.1+. Not available in ArcGIS Online. This parameter allows the desired item id to be specified during creation which can be useful for cloning and automated content creation scenarios. The specified id must be a 32 character GUID string without any special characters.

If the item_id is already being used, an error will be raised during the publish process.

Example: item_id=9311d21a9a2047d19c0faaebd6f2cca6

Returns

An arcgis.gis.Item object corresponding to the published web layer.

For publish_parameters, see https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm

property rating

Gets or sets the rating given by the current user to the item.

reassign_to(target_owner, target_folder=None)

Allows the administrator to reassign a single item from one user to another.

Note

If you wish to move all of a user’s items (and groups) to another user then use the user.reassign_to() method. This method only moves one item at a time.

Argument

Description

target_owner

Required string. The new desired owner of the item.

target_folder

Optional string. The folder to move the item to.

Returns

A boolean indicating success (True) with the ID of the reassigned item, or failure (False).

register(app_type, redirect_uris=None, http_referers=None, privileges=None)

The register method registers an app item with the enterprise. App registration results in an APPID and APPSECRET (also known as client_id and client_secret in OAuth speak, respectively) being generated for that app. Upon successful registration, a Registered App type keyword gets appended to the app item.

Available to the item owner.

Argument

Description

app_type

Required string. The type of app that was registered indicating whether it’s a browser app, native app, server app, or a multiple interface app. Values: browser, native, server, or multiple

redirect_uris

Optional list. The URIs where the access_token or authorization code will be delivered upon successful authorization. The redirect_uri specified during authorization must match one of the registered URIs, otherwise authorization will be rejected.

A special value of urn:ietf:wg:oauth:2.0:oob can also be specified for authorization grants. This will result in the authorization code being delivered to a portal URL (/oauth2/approval). This value is typically used by apps that don’t have a web server or a custom URI scheme where the code can be delivered.

The value is a JSON string array.

Example:

[

https://app.example.com”, “urn:ietf:wg:oauth:2.0:oob

]

http_referers

Optional List. A list of the http referrers for which usage of the API Key will be restricted to.

Example

` [ "https://foo.com", "https://bar.com" ] `

Note: Http Referrers can be configured for non apiKey type apps as well. The list configured here will be used to validate the app tokens sent in while accessing the sharing API. The referrer checks will not be applied to user tokens.

privileges

Optional List. A list of the privileges that will be available for this API key.

Example

```

[

“portal:apikey:basemaps”, “portal:app:access:item:itemId”, “premium:user:geocode”, “premium:user:networkanalysis”

]

``` Note: Privileges can be configured for non API Key type apps as well. The list configured here will be used to grant access to items when item endpoint is accessed with app tokens. The checks will not be applied to user tokens and they can continue accessing items based on the current item sharing model. With app tokens, all items of app owner can be accessed if the privileges list is not configured.

Returns

dict

related_items(rel_type, direction='forward')

Retrieves the items related to this item. Relationships can be added and deleted using item.add_relationship() and item.delete_relationship(), respectively.

Note

With WebMaps items, relationships are only available on local enterprises.

Argument

Description

rel_type

Required string. The type of the related item; is one of [‘Map2Service’, ‘WMA2Code’, ‘Map2FeatureCollection’, ‘MobileApp2Code’, ‘Service2Data’, ‘Service2Service’]. See Relationship Types. in the REST API help for more information on this parameter.

direction

Required string. One of [‘forward’, ‘reverse’]

Returns

The list of related items.

property resources

Returns the Item’s Resource Manager

Returns

ResourceManager

share(everyone=False, org=False, groups=None, allow_members_to_edit=False)

Shares an item with the specified list of groups.

Argument

Description

everyone

Optional boolean. Default is False, don’t share with everyone.

org

Optional boolean. Default is False, don’t share with the organization.

groups

Optional list of group ids as strings, or a list of arcgis.gis.Group objects, or a comma-separated list of group IDs.

allow_members_to_edit

Optional boolean. Default is False, to allow item to be shared with groups that allow shared update

Returns

A dictionary with key “notSharedWith” containing array of groups with which the item could not be shared.

property shared_with

Reveals the privacy or sharing status of the current item. An item can be private or shared with one or more of the following: A specified list of groups, to all members in the organization or to everyone (including anonymous users). If the return is False for org, everyone and contains an empty list of groups, then the item is private and visible only to the owner.

Returns

Dictionary of the following kind { ‘groups’: [], # one or more Group objects ‘everyone’: True | False, ‘org’: True | False }

status(job_id=None, job_type=None)

Provides the status when publishing an item, adding an item in async mode, or adding with a multipart upload. “Partial” is available for Add Item Multipart, when only a part is uploaded and the item is not committed.

Argument

Description

job_id

Optional string. The job ID returned during publish, generateFeatures, export, and createService calls.

job_type

Optional string. The type of asynchronous job for which the status has to be checked. Default is none, which checks the item’s status. This parameter is optional unless used with the operations listed below. Values: publish, generateFeatures, export, and createService

Returns

The status of a publishing item.

unregister()

The unregister app removes the application registration from an app item along with the Registered App type keyword.

The operation is available to item owner and organization administrators.

Available to the item owner.

Returns

boolean

unshare(groups)

Stops sharing of the item with the specified list of groups.

Argument

Description

groups

Optional list of group names as strings, or a list of arcgis.gis.Group objects, or a comma-separated list of group IDs.

Returns

Dictionary with key “notUnsharedFrom” containing array of groups from which the item could not be unshared.

update(item_properties=None, data=None, thumbnail=None, metadata=None)

Updates an item in a Portal.

Note

Content can be a file (such as a layer package, geoprocessing package, map package) or a URL (to an ArcGIS Server service, WMS service, or an application).

To upload a package or other file, provide a path or URL to the file in the data argument.

For item_properties, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the item’s description, then only provide the description argument in item_properties.

Argument

Description

item_properties

Required dictionary. See table below for the keys and values.

data

Optional string. Either a path or URL to the data.

thumbnail

Optional string. Either a path or URL to a thumbnail image.

metadata

Optional string. Either a path or URL to the metadata.

Key:Value Dictionary Options for Argument item_properties

Key

Value

type

Optional string. Indicates type of item, see URL 1 below for valid values.

typeKeywords

Optional string. Provide a lists all sub-types, see URL 1 below for valid values.

description

Optional string. Description of the item.

title

Optional string. Name label of the item.

url

Optional string. URL to item that are based on URLs.

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.

text

Optional string. For text based items such as Feature Collections & WebMaps

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

extent

Optional string. Provide comma-separated values for min x, min y, max x, max y.

spatialReference

Optional string. Coordinate system that the item is in.

accessInformation

Optional string. Information on the source of the content.

licenseInfo

Optional string. Any license information or restrictions regarding the content.

culture

Optional string. Locale, country and language information.

access

Optional string. Valid values are private, shared, org, or public.

commentsEnabled

Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).

URL 1: https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm

Returns

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

usage(date_range='7D', as_df=True)

ArcGIS Online Only

For item owners and administrators, usage provides usage details about an item that help you gauge its popularity. Usage details show how many times the item has been used for the time period you select. Historical usage information is available for the past year. Depending on the item type, usage details can include the number of views, requests, or downloads, and the average number of views, requests, or downloads per day.

Views refers to the number of times the item has been viewed or opened. For maps, scenes, nonhosted layers, and web apps, the view count is increased by one when you open the item page or open the item in Map Viewer. For example, if you opened the item page for a map image layer and clicked Open in Map Viewer, the count would increase by two. For other items such as mobile apps, KML, and so on, the view count is increased by one when you open the item; the count does not increase when you open the item details page.

For hosted web layers (feature, tile, and scene), the number of requests is provided instead of views. Requests refers to the number of times a request is made for the data within the layer. For example, someone might open an app that contains a hosted feature layer. Opening the app counts as one view for the application, but multiple requests may be necessary to draw all the features in the hosted layer and are counted as such.

For downloadable file item types such as CSV, SHP, and so on, the number of downloads is displayed. For registered apps, the Usage tab also displays the number of times users have logged in to the app. Apps that allow access to subscriber content through the organization subscription show usage by credits. You can change the time frame for the credit usage reporting period.

Argument

Description

date_range

Optional string. The default is 7d. This is the period to query usage for a given item.

24H

Past 24 hours

7D

Past 7 days (default)

14D

Past 14 days

30D

Past 30 days

60D

Past 60 days

6M

Past 6 months

1Y

Past 12 months

as_df

Optional boolean. Returns a Pandas DataFrame when True, returns data as a dictionary when False

Returns

Pandas DataFrame or Dictionary

User

class arcgis.gis.User(gis, username, userdict=None)

Bases: dict

Represents a registered user of the GIS (ArcGIS Online or ArcGIS Enterprise).

Property

Details

username

The username of the user.

fullName

The user’s full name

availableCredits

The number of credits available to the user.

assignedCredits

The number of credits allocated to the user.

firstName

The user’s first name.

lastName

The user’s last name.

preferredView

The user’s preferred view for content, either web or GIS.

description

A description of the user.

email

The user’s e-mail address.

idpUsername

The original username if using enterprise logins.

favGroupId

The user’s favorites group and is created automatically for each user.

lastLogin

The last login date of the user in milliseconds since the Unix epoch.

mfaEnabled

Indicates if the user’s account has multifactor authentication set up.

access

Indicates the level of access of the user: private, org, or public. If private, the user descriptive information will not be available to others nor will the username be searchable.

storageUsage

The amount of storage used for the entire organization.

NOTE: This value is an estimate for the organization, not the specific user. For storage estimate of a user’s items, see code example in the items method.

storageQuota

Applicable to public users as it sets the total amount of storage available for a subscription. The maximum quota is 2GB.

orgId

The ID of the organization the user belongs to.

role

Defines the user’s role in the organization.
Values:
  • org_admin - administrator or custom role with administrative privileges

  • org_publisher - publisher or custom role with publisher privileges

  • org_user - user or custom role with user privileges)

privileges

A JSON array of strings with predefined permissions in each. For a complete listing, see Privileges.

roleId

(Optional) The ID of the user’s role if it is a custom one.

level

The level of the user.

disabled

Disables access to the organization by the user.

units

User-defined units for measurement.

tags

User-defined tags that describe the user.

culture

The user locale information (language and country).

cultureFormat

The user preferred number and date format defined in CLDR (only applicable for English and Spanish, i.e. when culture is en or es).<br><br>See Languages for supported formats. It will inherit from organization cultureFormat if undefined.

region

The user preferred region, used to set the featured maps on the home page, content in the gallery, and the default extent of new maps in the Viewer.

thumbnail

The file name of the thumbnail used for the user.

created

The date the user was created. Shown in milliseconds since the Unix epoch.

modified

The date the user was last modified. Shown in milliseconds since the Unix epoch.

groups

A JSON array of groups the user belongs to. See Group for properties of a group.

provider

The identity provider for the organization.<br>Values: arcgis (for built-in users) ,enterprise (for external users managed by an enterprise identity store), facebook (for public accounts in ArcGIS Online), google (for public accounts in ArcGIS Online)

id

(optional) The unique identifier of the user used in ArcGIS Online or ArcGIS Enterprise 10.7+

property bundles

Provides the current user’s assigned application bundles.

Available in ArcGIS Online and Portal 10.7+

Returns

List of Bundle objects

delete(reassign_to=None)

Deletes this user from the portal, optionally deleting or reassigning groups and items.

Note

You can not delete a user in Portal if that user owns groups or items and/or is assigned an application bundle. If you specify someone in the reassign_to argument, then items and groups will be transferred to that user. If that argument is not set then the method will fail if the user has items or groups that need to be reassigned.

Argument

Description

reassign_to

Optional string. The new owner of the items and groups that belong to the user being deleted.

Returns

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

delete_thumbnail()

Removes the thumbnail from the user’s profile.

Returns

Boolean

disable()

Disables login access for the user. It is only available to the administrator of the organization.

Returns

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

download_thumbnail(save_folder=None)

Downloads the item thumbnail for this user.

Argument

Description

save_folder

Optional string. The desired folder name to download the thumbnail to.

Returns

The file path of the downloaded thumbnail.

enable()

Enables login access for the user. It is only available to the administrator of the organization.

property esri_access

When getting, will return a string describing the current user’s esri access When setting, supply a bool to enable or disable esri_access for that user (Administrator privileges required)

A member whose account has Esri access enabled can use My Esri and Community and Forums (GeoNet), access e-Learning on the Training website, and manage email communications from Esri. The member cannot enable or disable their own access to these Esri resources.

Trial accounts cannot modify esri_access property.

Please see: http://doc.arcgis.com/en/arcgis-online/administer/manage-members.htm#ESRI_SECTION1_7CE845E428034AE8A40EF8C1085E2A23 or https://bit.ly/2JsJV1i for more information.

property folders

Gets the list of the user’s folders

get_thumbnail()

Returns the bytes that make up the thumbnail for this user.

Returns

Bytes that represent the image.

Usage Example:

response = user.get_thumbnail()
f = open(filename, 'wb')
f.write(response)

Retrieves the URL to the thumbnail image.

Returns

The thumbnail’s URL.

property groups

Gets a list of Group objects the current user belongs to.

property homepage

Gets the URL to the HTML page for the user.

items(folder=None, max_items=100)

Provides a list of items in the specified folder. For content in the root folder, use the default value of None for the folder argument. For other folders, pass in the folder name as a string, or as a dictionary containing the folder ID, such as the dictionary obtained from the folders property.

Argument

Description

folder

Optional string. The specifc folder (as a string or dictionary) to get a list of items in.

max_items

Optional integer. The maximum number of items to be returned. The default is 100.

Returns

The list of items in the specified folder.

# Example to **estimate** storage for a user's items

storage = 0
for item in user.items():
    storage += item.size
try:
    for f in user.folders:
        for f_item in user.folders(folder=f):
            storage += f_item.size
    print(f"{user.username} using {storage} bytes")
except Exception as e:
    print(f"{user.username} using {storage} bytes")

If you use multiple accounts for ArcGIS Online and Esri websites, you can link them so you can switch between accounts and share your Esri customer information with My Esri, e-Learning, and GeoNet. You can link your organizational, public, enterprise, and social login accounts. Your content and privileges are unique to each account. From Esri websites, only Esri access-enabled accounts appear in your list of linked accounts.

See: http://doc.arcgis.com/en/arcgis-online/reference/sign-in.htm for addtional information.

Argument

Description

username

required string/User. This is the username or User object that a user wants to link to.

user_gis

required GIS. This is the GIS object for the username. In order to link an account, a user must be able to login to that account. The GIS object is the entry into that account.

returns: Boolean. True for success, False for failure.

property linked_accounts

returns all linked account for the current user as User objects

property notifications

Gets the list of notifications available for the given user.

property provisions

Returns a list of all provisioned licenses for the current user.

Available in 10.7+

Returns

List

reassign_to(target_username)

Reassigns all of this user’s items and groups to another user.

Items are transferred to the target user into a folder named <user>_<folder> where user corresponds to the user whose items were moved and folder corresponds to the folder that was moved.

Note

This method must be executed as an administrator. This method also can not be undone. The changes are immediately made and permanent.

Argument

Description

target_username

Required string. The user who will be the new owner of the items and groups from which these are being reassigned from.

Returns

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

reset(password=None, new_password=None, new_security_question=None, new_security_answer=None, reset_by_email=False)

Resets a user’s password, security question, and/or security answer.

Note

This function does not apply to those using enterprise accounts that come from an enterprise such as ActiveDirectory, LDAP, or SAML. It only has an effect on built-in users.

If a new security question is specified, a new security answer should be provided.

Note

To reset the password by email, set reset_by_email to True and password to None.

Argument

Description

password

Required string. The current password.

new_password

Optional string. The new password if resetting password.

new_security_question

Optional string. The new security question if desired.

new_security_answer

Optional string. The new security question answer if desired.

reset_by_email

Optional Boolean. If True, the user will be reset by email. The default is False.

Returns

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

property tasks

The resource manager for user’s tasks. See TaskManager.

When a user wishes to no longer have a linked account, the unlink method allows for the removal if linked accounts.

See: http://doc.arcgis.com/en/arcgis-online/reference/sign-in.htm for addtional information.

Argument

Description

username

required string/User. This is the username or User object that a user wants to unlink.

returns: boolean.

update(access=None, preferred_view=None, description=None, tags=None, thumbnail=None, fullname=None, email=None, culture=None, region=None, first_name=None, last_name=None, security_question=None, security_answer=None)

Updates this user’s properties.

Note

Only pass in arguments for properties you want to update. All other properties will be left as they are. If you want to update the description, then only provide the description argument.

Note

When updating the security question, you must provide a security_answer as well.

Argument

Description

access

Optional string. The access level for the user, values allowed are private, org, public.

preferred_view

Optional string. The preferred view for the user, values allowed are Web, GIS, null.

description

Optional string. A description of the user.

tags

Optional string. Tags listed as comma-separated values, or a list of strings.

thumbnail

Optional string. The path or url to a file of type PNG, GIF, or JPEG. Maximum allowed size is 1 MB.

fullname

Optional string. The full name of this user, only for built-in users.

email

Optional string. The e-mail address of this user, only for built-in users.

culture

Optional string. The two-letter language code, fr for example.

region

Optional string. The two-letter country code, FR for example.

first_name

Optional string. User’s first name.

last_name

Optional string. User’s first name.

security_question

Optional integer. The is a number from 1-14. The questions are as follows:

  1. What city were you born in?

  2. What was your high school mascot?

  3. What is your mother’s maden name?

  4. What was the make of your first car?

  5. What high school did you got to?

  6. What is the last name of your best friend?

  7. What is the middle name of your youngest sibling?

  8. What is the name of the street on which your grew up?

  9. What is the name of your favorite fictional character?

  10. What is the name of your favorite pet?

  11. What is the name of your favorite restaurant?

  12. What is the title of your facorite book?

  13. What is your dream job?

  14. Where did you go on your first date?

Usage Example:

security_question=13

security_answer

Optional string. This is the answer to security querstion. If you are changing a user’s question, an answer must be provided.

Usage example:

security_answer=”Working on the Python API”

Returns

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

update_level(level)

Allows only administrators of an organization to update the level of a user. Administrators can leverage two levels of membership when assigning roles and privileges to members. Membership levels allow organizations to control access to some ArcGIS capabilities for some members while granting more complete access to other members. Level 1 membership is designed for members who need privileges to view and interact with existing content, while Level 2 membership is for those who contribute, create, and share content and groups, in addition to other tasks.

Maximum user quota of an organization at the given level is checked before allowing the update.

Built-in roles including organization administrator, publisher, and user are assigned as Level 2, members with custom roles can be assigned as Level 1, 1PlusEdit, or Level 2.

Level 1 membership allows for limited capabilities given through a maximum of 8 privileges: portal:user:joinGroup, portal:user:viewOrgGroups, portal:user:viewOrgItems, portal:user:viewOrgUsers, premium:user:geocode, premium:user:networkanalysis, premium:user:demographics, and premium:user:elevation. If updating the role of a Level 1 user with a custom role that has more privileges than the eight, additional privileges will be disabled for the user to ensure restriction.

Level 1 users are not allowed to own any content or group which can be reassigned to other users through the Reassign Item and Reassign Group operations before downgrading them. The operation will also fail if the user being updated has got licenses assigned to premium apps that are not allowed at the targeting level.

Argument

Description

level

Required string. The values of 1 or 2. This is the user level for the given user.

  • 1 - View only

  • 2 - Content creator

Returns

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

update_license_type(user_type)

Allows for the updating of the user’s licensing type. This allows administrators to change a user from a creator to a viewer or any other custom user license type.

Available in ArcGIS Online and Portal 10.7+

Argument

Description

user_type

Required string. The user license type to assign a user.

Built-in Types: creator or viewer

Returns

Boolean

update_role(role)

Updates this user’s role to org_user, org_publisher, org_admin, viewer, view_only, viewplusedit, or a custom role.

Note

There are four types of roles in Portal - user, publisher, administrator and custom roles. A user can share items, create maps, create groups, etc. A publisher can do everything a user can do and additionally create hosted services. An administrator can do everything that is possible in Portal. A custom roles privileges can be customized.

Argument

Description

role

Required string. Value must be either org_user, org_publisher, org_admin, viewer, view_only, viewplusedit or a custom role object (from gis.users.roles).

Returns

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

user_types()

Notes: Available in 10.7+ returns the user type and assigned applications

Group

class arcgis.gis.Group(gis, groupid, groupdict=None)

Bases: dict

Represents a group within the GIS (ArcGIS Online or ArcGIS Enterprise).

add_users(usernames=None, admins=None)

Adds users to this group.

Note

This method will only work if the user for the Portal object is either an administrator for the entire Portal or the owner of the group.

Argument

Description

usernames

Optional list of strings or single string. The list of usernames or single username to be added.

admins

Optional List of String, or Single String. This is a list of users to be an administrator of the group.

Returns

A dictionary which contains the users that were not added to the group.

property applications

Gets the group applications for the given group as a list. Available to administrators of the group or administrators of an organization if the group is part of one.

property categories

The category manager for groups. See CategorySchemaManager.

content(max_items=1000)

Gets the list of items shared with this group.

Argument

Description

max_items

Required integer. The maximum number of items to be returned, defaults to 1000.

Returns

The list of items that are shared.

delete()

Deletes this group.

Returns

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

delete_group_thumbnail()

Deletes the group’s thumbnail

Returns

Boolean

download_thumbnail(save_folder=None)

Downloads the group thumbnail for this group.

Argument

Description

save_folder

Optional string. The file path to where the group thumbnail will be downloaded.

Returns

The file path to which the group thumbnail is downloaded.

get_members()

Gets the members of this group.

Key:Value Dictionary Return Values

Key

Value

owner

The group’s owner (string).

admins

The group’s admins (list of strings). Typically this is the same as the owner.

users

The members of the group (list of strings).

Returns

A dictionary with keys: owner, admins, and users.

# Usage Example: To print users in a group

response = group.get_members()
for user in response['users'] :
    print(user)
get_thumbnail()

Gets the bytes that make up the thumbnail for this group.

Returns

Bytes that represent the image.

Example

response = group.get_thumbnail()
f = open(filename, 'wb')
f.write(response)

URL to the thumbnail image

property homepage

Gets the URL to the HTML page for the group.

invite_by_email(email, message, role='member', expiration='1 Day')

Deprecated since version v1.5.1: Use Group.invite instead.

** Deprecated: This function is not supported **

Invites a user by email to the existing group.

Argument

Description

email

Required string. The user to send join email to.

message

Required string. The message to send to the user.

role

Optional string. Either member (the default) or admin.

expiration

Optional string. The is the time out of the invite. The values are: 1 Day (default), 3 Days, 1 Week, or 2 Weeks.

Returns

boolean

invite_users(usernames, role='group_member', expiration=10080)

Invites existing users to this group. The user executing this command must be the group owner.

Note

A user who is invited to this group will see a list of invitations in the “Groups” tab of Portal listing invitations. The user can either accept or reject the invitation.

Argument

Description

usernames

Required list of strings. The users to invite.

role

Optional string. Either group_member (the default) or group_admin.

expiration

Optional integer. Specifies how long the invitation is valid for in minutes. Default is 10,080 minutes (7 days).

Returns

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

join()

Users apply to join a group using the Join Group operation. This creates a new group application, which the group administrators accept or decline. This operation also creates a notification for the user indicating that they have applied to join this group. Available only to authenticated users. Users can only apply to join groups to which they have access. If the group is private, users will not be able to find it to ask to join it. Information pertaining to the applying user, such as their full name and username, can be sent as part of the group application.

Returns

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

leave()

Removes the logged in user from this group. It is required that the user be logged in.

Returns

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

property migration

provides to to migrate content of a Group to a new Organaization or Portal

notify(users, subject, message, method='email', client_id=None)

Creates a group notification that sends a message to all users within the group.

Argument

Description

users

Required List. A list of users or user names.

subject

Required String. The subject of the notification.

message

Required String. The message body that will be sent to the group’s users.

method

Optional String. This is the form for which users will be contacted. The allowed values are: email, push, and builtin.

  • email - sent a message via smtp.

  • push - pushes a message out.

  • builtin - creates a user notification.

client_id

Optional String. The client id of the application for the push operation.

Returns

Boolean

property protected

Indicates if the group is protected from deletion. Set it to True to protect the group and False to unprotect it.

reassign_to(target_owner)

Reassigns this group to another owner.

Argument

Description

target_owner

Required string or User. The username of the new group owner.

Returns

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

remove_users(usernames)

Remove users from this group.

Argument

Description

usernames

Required string. A comma-separated list of users to be removed.

Returns

A dictionary with a key notRemoved that is a list of users not removed.

search(query, return_count=False, max_items=100, bbox=None, categories=None, category_filter=None, start=1, sort_field='title', sort_order='ASC', as_dict=False)

The search operation allows users to find content within the specific group.

Argument

Description

query

Required String. The search query.

bbox

Optional String/List. This is the xmin,ymin,xmax,ymax bounding box to limit the search in. Items like documents do not have bounding boxes and will not be included in the search.

categories

Optional String. A comma separated list of up to 8 org content categories to search items. Exact full path of each category is required, OR relationship between the categories specified.

Each request allows a maximum of 8 categories parameters with AND relationship between the different categories parameters called.

category_filters

Optional String. A comma separated list of up to 3 category terms to search items that have matching categories. Up to 2 category_filters parameter are allowed per request. It can not be used together with categories to search in a request.

start

Optional Int. The starting position to search from. This is only required if paging is needed.

sort_field

Optional String. Responses from the search operation can be sorted on various fields. avgrating is the default.

sort_order

Optional String. The sequence into which a collection of records are arranged after they have been sorted. The allowed values are: asc for ascending and desc for descending.

as_dict

Required Boolean. If True, the response comes back as a dictionary.

Returns

List of Items

update(title=None, tags=None, description=None, snippet=None, access=None, is_invitation_only=None, sort_field=None, sort_order=None, is_view_only=None, thumbnail=None, max_file_size=None, users_update_items=False, clear_empty_fields=False, display_settings=None, is_open_data=False, leaving_disallowed=False)

Updates this group with only values supplied for particular arguments.

Argument

Description

title

Optional string. The new name of the group.

tags

Optional string. A comma-delimited list of new tags, or a list of tags as strings.

description

Optional string. The new description for the group.

snippet

Optional string. A new short snippet (<250 characters) that summarizes the group.

access

Optional string. Choices are private, public, or org.

is_invitation_only

Optional boolean. Defines whether users can join by request. True means an invitation is required.

sort_field

Optional string. Specifies how shared items with the group are sorted.

sort_order

Optional string. Choices are asc or desc for ascending or descending, respectively.

is_view_only

Optional boolean. Defines whether the group is searchable. True means the group is searchable.

thumbnail

Optional string. URL or file location to a new group image.

max_file_size

Optional integer. This is the maximum file size allowed be uploaded/shared to a group. Default value is: 1024000

users_update_items

Optional boolean. Members can update all items in this group. Updates to an item can include changes to the item’s description, tags, metadata, as well as content. This option can’t be disabled once the group has been created. Default is False.

clear_empty_fields

Optional Boolean. If True, the user can set values to empty string, else, None values will be ignored.

display_settings

Optional String. Defines the default display for the group page to show a certain type of items. The allowed values are: apps, all, files, maps, layers, scenes, tools. The default value is all.

is_open_data

Optional Boolean. Defines whether the group can be used in the Open Data capabilities of ArcGIS Hub. The default is False.

leaving_disallowed

Optional boolean. Defines whether users are restricted from choosing to leave the group. If True, only an administrator can remove them from the group. The default is False.

Returns

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

update_users_roles(managers: list = None, users: list = None) → list

Updates a set of users to either Group’s Managers or Members

Argument

Description

managers

Required List. A comma-separated array of User objects to upgrade to a group manager role.

users

Required List. A comma-separated array of User objects to make group member roles.

Returns

List[dict]

Datastore

class arcgis.gis.Datastore(datastore, path)

Bases: dict

Represents a datastore (folder, database or bigdata fileshare) within the GIS’s data store.

property datasets

Gets the datasets in the data store, as a dictionary (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).

property manifest

Gets or sets the manifest resource for bigdata fileshares, as a dictionary.

property ref_count

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

regenerate()

This regenerates the manifest for a big data file share. You can regenerate a manifest if you have added new data or if you have uploaded a hints file using the edit resource.

Returns

Boolean. True = Success, False = Failure

update(item)

Edits this data item to update its connection information.

Argument

Description

item

Required dictionary. The representation of the updated item.

Returns

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

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.

Returns

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

Role

class arcgis.gis.Role(gis, role_id, role)

Bases: object

A custom role in the GIS.

delete()

Deletes this role.

Returns

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

property description

Gets and sets the description of the custom role.

property name

Gets and sets the name of the custom role.

property privileges

Get or sets the privileges for the custom role as a list of strings.

Supported privileges with predefined permissions are:

Administrative Privileges:

Members

  • portal:admin:viewUsers: grants the ability to view full member account information within organization.

  • portal:admin:updateUsers: grants the ability to update member account information within organization.

  • portal:admin:deleteUsers: grants the ability to delete member accounts within organization.

  • portal:admin:inviteUsers: grants the ability to invite members to organization. (This privilege is only applicable to ArcGIS Online.)

  • portal:admin:disableUsers: grants the ability to enable and disable member accounts within organization.

  • portal:admin:changeUserRoles: grants the ability to change the role a member is assigned within organization; however, it does not grant the ability to promote a member to, or demote a member from, the Administrator role. That privilege is reserved for the Administrator role alone.

  • portal:admin:manageLicenses: grants the ability to assign licenses to members of organization.

  • portal:admin:reassignUsers: grants the ability to assign all groups and content of a member to another within organization.

Groups

  • portal:admin:viewGroups: grants the ability to view all groups within organization.

  • portal:admin:updateGroups: grants the ability to update groups within organization.

  • portal:admin:deleteGroups: grants the ability to delete groups within organization.

  • portal:admin:reassignGroups: grants the ability to reassign groups to other members within organization.

  • portal:admin:assignToGroups: grants the ability to assign members to, and remove members from, groups within organization.

  • portal:admin:manageEnterpriseGroups: grants the ability to link group membership to an enterprise group. (This privilege is only applicable to ArcGIS Enterprise.)

Content

  • portal:admin:viewItems: grants the ability to view all content within organization.

  • portal:admin:updateItems: grants the ability to update content within organization.

  • portal:admin:deleteItems: grants the ability to delete content within organization.

  • portal:admin:reassignItems: grants the ability to reassign content to other members within organization.

  • portal:admin:shareToGroup: grants the ability to share other member’s content to groups the user belongs to.

  • portal:admin:shareToOrg: grants the ability to share other member’s content to organization.

  • portal:admin:shareToPublic: grants the ability to share other member’s content to all users of the portal.

ArcGIS Marketplace Subscriptions

  • marketplace:admin:purchase: grants the ability to request purchase information about apps and data in ArcGIS Marketplace. (This privilege is only applicable to ArcGIS Online.)

  • marketplace:admin:startTrial: grants the ability to start trial subscriptions in ArcGIS Marketplace. (This privilege is only applicable to ArcGIS Online.)

  • marketplace:admin:manage: grants the ability to create listings, list items and manage subscriptions in ArcGIS Marketplace. (This privilege is only applicable to ArcGIS Online.)

Publisher Privileges:

Content

  • portal:publisher:publishFeatures: grants the ability to publish hosted feature layers from shapefiles, CSVs, etc.

  • portal:publisher:publishTiles: grants the ability to publish hosted tile layers from tile packages, features, etc.

  • portal:publisher:publishScenes: grants the ability to publish hosted scene layers.

User Privileges:

Groups

  • portal:user:createGroup: grants the ability for a member to create, edit, and delete their own groups.

  • portal:user:joinGroup: grants the ability to join groups within organization.

  • portal:user:joinNonOrgGroup: grants the ability to join groups external to the organization. (This privilege is only applicable to ArcGIS Online.)

Content

  • portal:user:createItem: grants the ability for a member to create, edit, and delete their own content.

Sharing

  • portal:user:shareToGroup: grants the ability to share content to groups.

  • portal:user:shareToOrg: grants the ability to share content to organization.

  • portal:user:shareToPublic: grants the ability to share content to all users of portal.

  • portal:user:shareGroupToOrg: grants the ability to make groups discoverable by the organization.

  • portal:user:shareGroupToPublic: grants the ability to make groups discoverable by all users of portal.

Premium Content

  • premium:user:geocode: grants the ability to perform large-volume geocoding tasks with the Esri World Geocoder such as publishing a CSV of addresses as hosted feature layer.

  • premium:user:networkanalysis: grants the ability to perform network analysis tasks such as routing and drive-time areas.

  • premium:user:geoenrichment: grants the ability to geoenrich features.

  • premium:user:demographics: grants the ability to make use of premium demographic data.

  • premium:user:spatialanalysis: grants the ability to perform spatial analysis tasks.

  • premium:user:elevation: grants the ability to perform analytical tasks on elevation data.

Features

  • features:user:edit: grants the ability to edit features in editable layers, according to the edit options enabled on the layer.

  • features:user:fullEdit: grants the ability to add, delete, and update features in a hosted feature layer regardless of the editing options enabled on the layer.

Open Data

  • opendata:user:openDataAdmin: grants the ability to manage Open Data Sites for the organization. (This privilege is only applicable to ArcGIS Online.)

  • opendata:user:designateGroup: grants the ability to designate groups within organization as being available for use in Open Data. (This privilege is only applicable to ArcGIS Online.)

Layer

class arcgis.gis.Layer(url, gis=None)

Bases: arcgis.gis._GISResource

The layer is a primary concept for working with data in a GIS.

Users create, import, export, analyze, edit, and visualize layers.

Layers can be added to and visualized using maps. They act as inputs to and outputs from analysis tools.

Layers are created by publishing data to a GIS, and are exposed as a broader resource (Item) in the GIS. Layer objects can be obtained through the layers attribute on layer Items in the GIS.

classmethod fromitem(item, index=0)

Returns the layer at the specified index from a layer item.

Argument

Description

item

Required string. An item ID representing a layer.

index

Optional int. The index of the layer amongst the item’s layers

Returns

The layer at the specified index.

GroupApplication

class arcgis.gis.GroupApplication(url, gis, **kwargs)

Bases: object

Represents a single group application on the GIS (ArcGIS Online or ArcGIS Enterprise).

accept()

When a user applies to join a group, a group application is created. Group administrators choose to accept this application using the Accept Group Application operation. This operation adds the applying user to the group then deletes the application. This operation also creates a notification for the user indicating that the user’s group application was accepted. Available only to group owners and admins.

Returns

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

decline()

When a user applies to join a group, a group application is created. Group administrators can decline this application using this method. This method deletes the application and creates a notification for the user indicating that the user’s group application was declined. The applying user will not be added to the group. Available only to group owners and admins.

Returns

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

property properties

Gets the properties of the Group application.

CategorySchemaManager

class arcgis.gis.CategorySchemaManager(base_url, gis=None)

Helper class for managing category schemas. This class is not created by users directly. An instance of this class, called categories, is available as a property on gis.content or on gis.groups.

assign_to_items(items)

This function adds group content categories to the portal items specified in the items argument (see below). For assigning categories to items in a group, you must be the group owner/manager. For assigning organization content categories on items, you must be the item owner or an administrator who has the portal:admin:updateItems privilege. A maximum of 100 items can be bulk updated per request.

Argument

Description

items

Required List. A JSON array of item objects. Each is specified with the item ID that consists of a categories object. categories is specified with an array that lists all content categories to update on the item, each with full hierarchical path prefixed with /.

Each item can be categorized to a maximum of 20 categories.

Example
[{
“2678d3002eea4e4a825e3bdf10016e61”: {

“categories”: [“/Categories/Geology”, “/Categories/Elevation”]

}

}, {
“c3ad4ed8bcf04d619537cfe252a1760d”: {

“categories”: [“/Categories/Geology”, “/Categories/Land cover/Forest/Deciduous Forest”]

}

}, {
“9ced00fdce3e4b20bb4b05155acbe817”: {

“categories”: []

}

}]

Returns

A dict of item_id : status, with status being

whether the content categories were successfully added. If the status is unsuccessfully updated, a message will provide information to help you debug the issue.

delete()

This function allows group owner or managers to remove the category schema set on a group.

Returns

Boolean

property properties

Returns the properties of the schema.

property schema

This property allows group owners/managers to manage the content categories for a group. These content categories are a hierarchical set of classes to help organize and browse group content.

Each group can have a maximum of 5 category trees with each category schema can have up to 4 hierarchical levels. The maximum number of categories a group can have in total is 200 with each category of less than 100 characters title and 300 characters description.

When getting this property, returns the content category schema set on a group.

When setting this property, will update the group category schema based on the dict this property is set to. See below.

Argument

Description

categories

Required Dict. A category schema object consists of an array of dict objects representing top level categories. Each object has title, description and categories properties where categories consists of an array of objects with each having the same properties and represents the descendant categories or subcategories and so on.

ContentManager

class arcgis.gis.ContentManager(gis)

Helper class for managing content in ArcGIS Online or ArcGIS Enterprise. This class is not created by users directly. An instance of this class, called ‘content’, is available as a property of the GIS object. Users call methods on this ‘content’ object to manipulate (create, get, search, etc) items.

add(item_properties, data=None, thumbnail=None, metadata=None, owner=None, folder=None, item_id=None, **kwargs)

Adds content to the GIS by creating an item.

Note

Content can be a file (such as a service definition, shapefile, CSV, layer package, file geodatabase, geoprocessing package, map package) or it can be a URL (to an ArcGIS Server service, WMS service, or an application).

If you are uploading a package or other file, provide a path or URL to the file in the data argument.

From a technical perspective, none of the item_properties (see table below Key:Value Dictionary Options for Argument item_properties) are required. However, it is strongly recommended that arguments title, type, typeKeywords, tags, snippet, and description be provided.

Argument

Description

item_properties

Required dictionary. See table below for the keys and values.

data

Optional string. Either a path or URL to the data.

thumbnail

Optional string. Either a path or URL to a thumbnail image.

metadata

Optional string. Either a path or URL to the metadata.

owner

Optional string. Defaults to the logged in user.

folder

Optional string. Name of the folder where placing item.

item_id

Optional string. Available in ArcGIS Enterprise 10.8.1+. Not available in ArcGIS Online. This parameter allows the desired item id to be specified during creation which can be useful for cloning and automated content creation scenarios. The specified id must be a 32 character GUID string without any special characters.

If the item_id is already being used, an error will be raised during the add process.

Example: item_id=9311d21a9a2047d19c0faaebd6f2cca6

Optional Input Parameters for the `add` method

Optional Argument

Description

upload_size

Optional float. The default value is 1e7 bytes or ~10 MBs. This the minimum default value for the size of the file when uploading by parts.

Key:Value Dictionary Options for Argument item_properties

Key

Value

type

Optional string. Indicates type of item, see URL 1 below for valid values.

dataUrl

Optional string. The Url of the data stored on cloud storage. If given, filename is required.

filename

Optional string. The name of the file on cloud storage. This is required is dataUrl is used.

typeKeywords

Optional string. Provide a lists all sub-types, see URL 1 below for valid values.

description

Optional string. Description of the item.

title

Optional string. Name label of the item.

url

Optional string. URL to item that are based on URLs.

text

Optional string. For text based items such as Feature Collections & WebMaps

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

extent

Optional string. Provide comma-separated values for min x, min y, max x, max y.

spatialReference

Optional string. Coordinate system that the item is in.

accessInformation

Optional string. Information on the source of the content.

licenseInfo

Optional string. Any license information or restrictions regarding the content.

culture

Optional string. Locale, country and language information.

commentsEnabled

Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).

culture

Optional string. Language and country information.

overwrite

Optional boolean. Default is false. Controls whether item can be overwritten.

URL 1: Item and Item Types

Returns

The item if successfully added, None if unsuccessful.

This method allows the ability to fully customize the search experience. The advanced_search method allows users to control of the finer grained parameters not exposed by the ‘search’ method. Additionally, it allows for the manual paging of information and how the data is returned.

Argument

Description

query

Required String. The search query.

bbox

Optional String/List. This is the xmin,ymin,xmax,ymax bounding box to limit the search in. Items like documents do not have bounding boxes and will not be included in the search.

categories

Optional String. A comma separated list of up to 8 org content categories to search items. Exact full path of each category is required, OR relationship between the categories specified.

Each request allows a maximum of 8 categories parameters with AND relationship between the different categories parameters called.

category_filters

Optional String. A comma separated list of up to 3 category terms to search items that have matching categories. Up to 2 category_filters parameter are allowed per request. It can not be used together with categories to search in a request.

start

Optional Int. The starting position to search from. This is only required if paging is needed.

sort_field

Optional String. Responses from the search operation can be sorted on various fields. avgrating is the default.

sort_order

Optional String. The sequence into which a collection of records are arranged after they have been sorted. The allowed values are: asc for ascending and desc for descending.

count_fields

Optional String. A comma separated list of fields to count. Maximum count fields allowed per request is 3. Supported count fields: tags, type, access, contentstatus, and categories.

count_size

Optional Int. The maximum number of field values to count for each count_fields. The default value is None, and maximum size allowed is 200.

as_dict

Required Boolean. If True, the response comes back as a dictionary.

Returns

Depends on the inputs. - Dictionary for a standard search - return_count`=True an integer is returned - `count_fields is specified a list of dicts for each field specified

analyze(url=None, item=None, file_path=None, text=None, file_type=None, source_locale='en', geocoding_service=None, location_type=None, source_country='world', country_hint=None)

The Analyze call helps a client analyze a CSV or Excel file (.xlsx, .xls) prior to publishing or generating features using the Publish or Generate operation, respectively.

Analyze returns information about the file including the fields present as well as sample records. Analyze attempts to detect the presence of location fields that may be present as either X,Y fields or address fields.

Analyze packages its result so that publishParameters within the JSON response contains information that can be passed back to the server in a subsequent call to Publish or Generate. The publishParameters subobject contains properties that describe the resulting layer after publishing, including its fields, the desired renderer, and so on. Analyze will suggest defaults for the renderer.

In a typical workflow, the client will present portions of the Analyze results to the user for editing before making the call to Publish or Generate.

If the file to be analyzed currently exists in the portal as an item, callers can pass in its itemId. Callers can also directly post the file. In this case, the request must be a multipart post request pursuant to IETF RFC1867. The third option for text files is to pass the text in as the value of the text parameter.

Argument

Description

url

optional string. The URL of the csv file.

item

optional string/Item. The ID or Item of the item to be analyzed.

file_path

optional string. The file to be analyzed.

text

optional string. The text in the file to be analyzed.

file_type

optional string. The type of the input file: shapefile, csv, excel, or geoPackage (Added ArcGIS API for Python 1.8.3+).

source_locale

optional string. The locale used for the geocoding service source.

geocoding_service

optional string/geocoder. The URL of the service.

location_type

optional string. Indicates the type of spatial information stored in the dataset.

Values for CSV: coordinates | address | lookup | none Values for Excel: coordinates | address | none

source_country

optional string. The two character country code associated with the geocoding service, default is “world”.

country_hint

optional string. If first time analyzing, the hint is used. If source country is already specified than sourcecountry is used.

Returns

dictionary

bulk_update(itemids, properties)

Updates a collection of items’ properties.

Example:

>>> itemsids = gis.content.search("owner: TestUser12399")
>>> properties = {'categories' : ["clothes","formal_wear/socks"]}
>>> gis.content._bulk_update(itemids, properties)
[{'results' : [{'itemid' : 'id', 'success' : "True/False" }]}]

Argument

Description

itemids

Required list of string or Item. The collection of Items to update.

properties

Required dictionary. The Item’s properties to update.

Returns

list of results

can_delete(item)

The ‘can_delete’ Item indicates whether an item can be erased or not. When the returned response from ‘can_delete’ Item is true, the item can be safely removed. When the returned response is false, the item cannot be deleted due to a dependency or protection setting.

Argument

Description

item

Required Item. The Item to be erased.

Returns

Dict

Status

Response

success

{ “itemId”: “e03f626be86946f997c29d6dfc7a9666”, “success”: True }

failure

{ “itemId”: “a34c2e6711494e62b3b8d7452d4d6235”, “success”: false, “reason”: { “message”: “Unable to delete item. Delete protection is turned on.” } }

property categories

The category manager for items. See CategorySchemaManager.

clone_items(items, folder=None, item_extent=None, use_org_basemap=False, copy_data=True, copy_global_ids=False, search_existing_items=True, item_mapping=None, group_mapping=None, owner=None)

Clone content to the GIS by creating new items.

Cloning an item will create a copy of the item and for certain item types a copy of the item dependencies in the GIS.

For example a web application created using Web AppBuilder or a Configurable App Template which is built from a web map that references one or more hosted feature layers. This function will clone all of these items to the GIS and swizzle the paths in the web map and web application to point to the new layers.

This creates an exact copy of the application, map, and layers in the GIS.

Argument

Description

items

Required list. Collection of Items to clone.

folder

Optional string. Name of the folder where placing item.

item_extent

Optional Envelope. Extent set for any cloned items. Default is None, extent will remain unchanged. Spatial reference of the envelope will be used for any cloned feature layers.

use_org_basemap

Optional boolean. Indicating whether the basemap in any cloned web maps should be updated to the organizations default basemap. Default is False, basemap will not change.

copy_data

Optional boolean. Indicating whether the data should be copied with any feature layer or feature collections. Default is True, data will be copied.

copy_global_ids

Optional boolean. Assumes previous parameter is set to True. If True, features copied will preserve their global IDs. Default is False

search_existing_items

Optional boolean. Indicating whether items that have already been cloned should be searched for in the GIS and reused rather than cloned again.

item_mapping

Optional dictionary. Can be used to associate an item id in the source GIS (key) to an item id in the target GIS (value). The target item will be used rather than cloning the source item.

group_mapping

Optional dictionary. Can be used to associate a group id in the source GIS (key) to a group id in the target GIS (value). The target group will be used rather than cloning the source group.

owner

Optional string. Defaults to the logged in user.

Returns

A list of items created during the clone.

create_folder(folder, owner=None)

Creates a folder with the given folder name, for the given owner. Does nothing if the folder already exists. If owner is not specified, owner is set as the logged in user.

Argument

Description

folder

Required string. The name of the folder to create for the owner.

owner

Optional string. User, folder owner, None for logged in user.

Returns

A json object like the following if the folder was created: {“username” : “portaladmin”,”id” : “bff13218991c4485a62c81db3512396f”,”title” : “testcreate”}; None otherwise.

create_service(name, service_description='', has_static_data=False, max_record_count=1000, supported_query_formats='JSON', capabilities=None, description='', copyright_text='', wkid=102100, create_params=None, service_type='featureService', owner=None, folder=None, item_properties=None, is_view=False, tags=None, snippet=None, item_id=None)

Creates a service in the Portal.

Argument

Description

name

Required string. The unique name of the service.

service_description

Optional string. Description of the service.

has_static_data

Optional boolean. Indicating whether the data can change. Default is True, data is not allowed to change.

max_record_count

Optional integer. Maximum number of records in query operations.

supported_query_formats

Optional string. Formats in which query results are returned.

capabilities

Optional string. Specify service capabilities. If left unspecified, ‘Image,Catalog,Metadata,Download,Pixels’ are used for image services, and ‘Query’ is used for feature services, and ‘Query’ otherwise

description

Optional string. A user-friendly description for the published dataset.

copyright_text

Optional string. The copyright information associated with the dataset.

wkid

Optional integer. The well known id (WKID) of the spatial reference for the service. All layers added to a hosted feature service need to have the same spatial reference defined for the feature service. When creating a new empty service without specifying its spatial reference, the spatial reference of the hosted feature service is set to the first layer added to that feature service.

create_params

Optional dictionary. Add all create_service parameters into a dictionary. If this parameter is used, all the parameters above are ignored.

service_type

Optional string. The type of service to be created. Currently the options are imageService or featureService.

owner

Optional string. The username of the owner of the service being created.

folder

Optional string. The name of folder in which to create the service.

item_properties

Optional dictionary. See below for the keys and values

is_view

Optional boolean. Indicating if the service is a hosted feature layer view

item_id

Optional string. Available in ArcGIS Enterprise 10.8.1+. Not available in ArcGIS Online. This parameter allows the desired item id to be specified during creation which can be useful for cloning and automated content creation scenarios. The specified id must be a 32 character GUID string without any special characters.

If the item_id is already being used, an error will be raised during the add process.

Example: item_id=9311d21a9a2047d19c0faaebd6f2cca6

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

Key:Value Dictionary Options for Argument item_properties

Key

Value

type

Optional string. Indicates type of item, see URL 1 below for valid values.

typeKeywords

Optional string. Provide a lists all sub-types, see URL 1 below for valid values.

description

Optional string. Description of the item.

title

Optional string. Name label of the item.

url

Optional string. URL to item that are based on URLs.

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.

snippet

Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.

extent

Optional string. Provide comma-separated values for min x, min y, max x, max y.

spatialReference

Optional string. Coordinate system that the item is in.

accessInformation

Optional string. Information on the source of the content.

licenseInfo

Optional string. Any license information or restrictions regarding the content.

culture

Optional string. Locale, country and language information.

access

Optional string. Valid values are private, shared, org, or public.

commentsEnabled

Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).

culture

Optional string. Language and country information.

Returns

The item for the service if successfully created, None if unsuccessful.

delete_folder(folder, owner=None)

Deletes a folder for the given owner (logged in user by default) with the given folder name.

Argument

Description

folder

Required string. The name of the folder to delete.

owner

Optional string. User, folder owner, None for logged in user is the default.

Returns

True if folder deletion succeeded, False if folder deletion failed.

delete_items(items)

Deletes a collection of items from a users content.

Argument

Description

items

list of Item or Item Ids. This is an array of items to be deleted from the current user’s content

Returns: boolean. True on

generate(item=None, file_path=None, url=None, text=None, publish_parameters=None, future=False)

The Generate call helps a client generate features from a CSV file, shapefile, GPX, or GeoJson file types.

Argument

Description

item

Optional Item. An Item on the current portal.

file_path

Optional String. The file resource location on local disk.

url

Optional String. A web resource of a ‘shapefile’, ‘csv’, ‘gpx’ or ‘geojson’ file.

text

Optional String. The source text.

publish_parameters

Optional Dict. A Python dictionary describing the layer and service to be created as part of the publish operation. The appropriate key-value pairs depend on the file type being published. For a complete description, see the Publish Item documentation in the REST API. Also see the Item publish() method. CSV, Shapefiles and GeoJSON file types must have publish parameters provided.

future

Optional Boolean. This allows the operation to run asynchronously allowing the user to not pause the thread and continue to perform multiple operations. The default is True. When True the result of the method will be a concurrent Future object. The result of the method can be obtained using the result() on the Future object. When False, and Item is returned. Future == True is only supported for ‘shapefiles’ and ‘gpx’ files.

Returns

Future object when future==True, Item when future==False, dict of error messages on Exceptions

get(itemid)

Returns the item object for the specified itemid.

Argument

Description

itemid

Required string. The item identifier.

Returns

The item object if the item is found, None if the item is not found.

import_data(df, address_fields=None, folder=None, item_id=None, **kwargs)

Imports a Pandas data frame (that has an address column), or an arcgis spatial dataframe into the GIS.

Spatial dataframes are imported into the GIS and published as feature layers. Pandas dataframes that have an address column are imported as an in-memory feature collection. Note: By default, there is a limit of 1,000 rows/features for Pandas dataframes. This limit isn’t there for spatial dataframes.

Argument

Description

df

Required string. Pandas dataframe or arcgis.SpatialDataFrame

address_fields

Optional dictionary. Dictionary containing mapping of df columns to address fields, eg: { “CountryCode” : “Country”} or { “Address” : “Address” }.

folder

Optional string. Name of the folder where imported data would be stored.

title

Optional string. Title of the item. This is used for spatial dataframe objects.

tags

Optional string. Tags listed as comma-separated values, or a list of strings. Provide tags when publishing a spatial dataframe to the the GIS.

item_id

Optional string. Available in ArcGIS Enterprise 10.8.1+. Not available in ArcGIS Online. This parameter allows the desired item id to be specified during creation which can be useful for cloning and automated content creation scenarios. The specified id must be a 32 character GUID string without any special characters.

If the item_id is already being used, an error will be raised during the add process.

Example: item_id=9311d21a9a2047d19c0faaebd6f2cca6

In addition to the parameters aboce, you can specify additional information to help publish CSV data.

Optional Argument

Description

location_type

Optional string. Indicates the type of spatial information stored in the dataset.

Values for CSV:

  • coordinates

  • address (default)

  • lookup

  • none

Values for Excel:

  • coordinates

  • address (default)

  • none

When location_type = coordinates, the CSV or Excel data contains x,y information. When location_type = address, the CSV or Excel data contains address fields that will be geocoded to a single point. When location_type = lookup, the CSV or Excel data contains fields that can be mapped to well-known sets of geographies. When location_type = none, the CSV or Excel data contains no spatial content and data will be loaded and subsequently queried as tabular data.

Based on this parameter, additional parameters will be required, for example, when specifying location_type = coordinates, the latitude and longitude field names must be specified.

latitude_field

Optional string. If location_type = coordinates, the name of the field that contains the y coordinate.

longitude_field

Optional string. If location_type = coordinates, the name of the field that contains the x coordinate.

coordinate_field_type

Optional string. Specify the type of coordinates that contain location information. Values: LatitudeAndLongitude (default), MGRS, USNG

coordinate_field_name

Optional string. The name of the field that contains the coordinates specified in coordinate_field_type

lookup_type

Optional string. The type of place to look up.

lookup_fields

Optional string. A JSON object with name value pairs that define the fields used to look up the location.

geocode_url

Optional string. The URL of the geocoding service that supports batch geocoding.

source_locale

Optional string. The locale used for the geocoding service source.

source_country

Optional string. The two character country code associated with the geocoding service, default is ‘world’.

country_hint

Optional string. If first time analyzing, the hint is used. If source country is already specified than source_country is used.

When publishing a Spatial Dataframe, additional options can be given:

Optional Argument

Description

target_sr

optional integer. WKID of the output data. This is used when publishing Spatial Dataframes to Hosted Feature Layers. The default is: 102100

title

optional string. Name of the layer. The default is a random string.

tags

optional string. Comma seperated strings that provide metadata for the items. The default is FGDB.

capabilities

optional string. specifies the operations that can be performed on the feature layer service. The default is Query.

Returns

A feature collection or feature layer that can be used for analysis, visualization, or published to the GIS as an item.

is_service_name_available(service_name, service_type)

For a desired service name, determines if that service name is available for use or not.

Argument

Description

service_name

Required string. A desired service name.

service_type

Required string. The type of service to be created. Currently the options are imageService or featureService.

Returns

True if the specified service_name is available for the

specified service_type, False if the service_name is unavailable.

rename_folder(old_folder, new_folder, owner=None)

Renames an existing folder from it’s existing name to a new name. If owner is not specified, owner is set as the logged in user.

Argument

Description

old_folder

Required string. The name of the folder to rename for the owner.

new_folder

Required string. The new name of the folder.

owner

Optional string. User, folder owner, None for logged in user.

Returns

Boolean

replace_service(replace_item, new_item, replaced_service_name=None, replace_metadata=False)

The replace_service operation allows you to replace your production vector tile layers with staging ones. This operation allows you to perform quality control on a staging tile layer and to then replace the production tile layer with the staging with minimal downtime. This operation has the option to keep a backup of the production tile layer.

Note: This functionality is only available for hosted vector tile layers, hosted tile layers and hosted scene layers based on packages.

Note: If you are looking to clone services, use the clone_items() method instead.

Workflow for replace_service:

1. Publish the staging service to the same system as the production service. Both services are active at the same time. Share the staging service with a smaller set of users and QA the staging service.

2. The item properties (ex: thumbnail, iteminfo, metadata) of the production item will be preserved. If you need to update them use the Item.update() method.

3. Call the replace_service operation. The service running on the hosting server gets replaced (for example, its cache).

*Note: It is the responsibility of the user to ensure both services are functionally equivalent for clients consuming them. For example, when replacing a hosted feature service, ensure the new service is constructed with the anticipated layers and fields for its client application.

If you want to retain the replaced production service, for example, to keep an archive of the evolution of the service you can do so by omitting a value for “Replaced Service Name” . If replaced service name is not provided, the production service being replaced will be archived with a time stamp when replace service was executed. You can provide any name for the replaced service as long as it is not pre-existing on your portal content.

Argument

Description

replace_item

Required Item or Item’s Id as string. The service to be replaced

new_item

Required Item or Item’s Id as string. The replacement service.

replaced_service_name

Optional string. The name of the replacement service.

replace_metadata

Optional Boolean. When set to True, the item info {“thumbnail”, “tag”, “description”, “summary”} of the current service is updated to that of the replacement service. The Credits, Terms of use, and Created from details will not be replaced. This option is set to False by default.

Returns

boolean

search(query, item_type=None, sort_field='avgRating', sort_order='desc', max_items=10, outside_org=False, categories=None, category_filters=None)

Searches for portal items.

Note

A few things that will be helpful to know…

  1. The query syntax has many features that can’t be adequately described here. The query syntax is available in ArcGIS Help. A short version of that URL is http://bitly.com/1fJ8q31.

  2. Most of the time when searching for items, you’ll want to search within your organization in ArcGIS Online or within your Portal. As a convenience, the method automatically appends your organization id to the query by default. If you want content from outside your organization set outside_org to True.

Argument

Description

query

Required string. A query string. See notes above.

item_type

Optional string. Set type of item to search. https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm

sort_field

Optional string. Valid values can be title, uploaded, type, owner, modified, avgRating, numRatings, numComments, and numViews.

sort_order

Optional string. Valid values are asc or desc.

max_items

Optional integer. Maximum number of items returned, default is 10.

outside_org

Optional boolean. Controls whether to search outside your org (default is False, do not search ourside your org).

categories

Optional string or list. A string of category values.

category_filters

Optional string. A comma separated list of up to 3 category terms to search items that have matching categories.

Up to 2 category_filters parameter are allowed per request. It can not be used together with categories to search in a request.

Returns

A list of items matching the specified query.

share_items(items, everyone=False, org=False, groups=None, allow_members_to_edit=False)

Shares a batch of items with everyone, members of the organization, or specified list of groups. Users can only share items with groups to which they belong.

Argument

Description

items

Required List. A list of Item or item ids to modify sharing on.

everyone

Optional boolean. Default is False, don’t share with everyone.

org

Optional boolean. Default is False, don’t share with the organization.

groups

Optional list of group names as strings, or a list of arcgis.gis.Group objects, or a comma-separated list of group IDs.

allow_members_to_edit

Optional boolean. Default is False, to allow item to be shared with groups that allow shared update

Returns

dict

unshare_items(items, groups=None, everyone=None, org=None)

Unshares a batch of items with the specified list of groups, everyone, or organization. Each item’s current sharing will be overwritten with this method.

Argument

Description

items

Required List. A list of Item or item ids to modify sharing on.

everyone

Required Boolean. If provided, the everyone sharing property will be updated. True means it will share the items with anyone. False means the item will not be shared with all users.

org

Required Boolean. A true value means that the items will be shared with all members of the organization. A false value means that the item will not be shared with all organization users.

groups

Required list of group names as strings, or a list of arcgis.gis.Group objects, or a list of group IDs.

Returns

dict

UserManager

class arcgis.gis.UserManager(gis)

Bases: object

Helper class for managing GIS users. This class is not created by users directly. An instance of this class, called ‘users’, is available as a property of the Gis object. Users call methods on this ‘users’ object to manipulate (create, get, search, etc) users.

The advanced_search method allows for the full control of the query operations by any given user. The searches are performed against a high performance index that indexes the most popular fields of an user. See the Search reference page for information on the fields and the syntax of the query.

The search index is updated whenever users is added, updated, or deleted. There can be a lag between the time that the user is updated and the time when it’s reflected in the search results.

The results of a search only contain items that the user has permission to access.

Argument

Description

query

Required String. The search query.

return_count

Optional Boolean. If True, the number of users found by the query string is returned.

max_users

Optional Integer. Limits the total number of users returned in a a query. The default is 10 users. If all users is needed, -1 should be used.

start

Optional Int. The starting position to search from. This is only required if paging is needed.

sort_field

Optional String. Responses from the search operation can be sorted on various fields. avgrating is the default.

sort_order

Optional String. The sequence into which a collection of records are arranged after they have been sorted. The allowed values are: asc for ascending and desc for descending.

as_dict

Required Boolean. If True, the response comes back as a dictionary.

Returns

dictionary if return_count is False, else an integer

counts(type='bundles', as_df=True)

This method returns a simple report on the number of licenses currently used for a given type. A type can be a role, app, bundle or user license type.

Argument

Description

type

Required String. The type of data to return. The following values are valid:

  • role - returns counts on user roles

  • app - returns counts on registered applications

  • bundles - returns counts on application bundles

  • user_type - returns counts on the user license types

as_df

Optional boolean. If true, the results are returned as a pandas DataFrame, else it is returned as a list of dictionaries.

Returns

Pandas DataFrame if as_df is True. If False, the result is a list of dictionaries.

Example as_df=True

>>> df = gis.um.counts('user_type', True)
>>> df
    count        key
 0     12  creatorUT
 1      2   viewerUT

Example as_df=False

>>> df = gis.um.counts('user_type', False)
>>> df
[{'key': 'creatorUT', 'count': 12}, {'key': 'viewerUT', 'count': 2}]
create(username, password, firstname, lastname, email, description=None, role=None, provider='arcgis', idp_username=None, level=2, thumbnail=None, user_type=None, credits=- 1, groups=None)

This operation is used to pre-create built-in or enterprise accounts within the Enterprise portal, or built-in users in an ArcGIS Online organization account. Only an administrator can call this method.

To create a viewer account, choose role=’org_viewer’ and level=’viewer’

Argument

Description

username

Required string. The username must be unique and 6-24 characters long.

password

Required string. The password for the user. It must be at least 8 characters. This is a required parameter if the provider is arcgis; otherwise, the password parameter is ignored. If creating an account in an ArcGIS Online org, it can be set as None to let the user set their password by clicking on a link that is emailed to them.

firstname

Required string. The first name for the user

lastname

Required string. The last name for the user

email

Required string. The email address for the user. This is important to have correct.

description

Optional string. The description of the user account.

thumbnail

Optional string. The URL to user’s image.

role

Optional string. The role for the user account. The default value is org_user. Other possible values are org_publisher, org_admin, viewer, viewplusedit or a custom role_id value obtained from the all() method of the RoleManager class.

# Usage Example: Assign custom role to a new user

>>> role_mgr = gis.users.roles

>>> for role in role_mgr.all():
>>>     print(f"{role.name}  {role.role_id}")

    Viewer              iAAAAAAAAAAAAAAA
    Data Editor         iBBBBBBBBBBBBBBB
    CustomRole          bKrTCjFF9tKbaFk8

>>> gis.users.create(username='new_user_1',
                     password='<strong_password>',
                     firstname='New',
                     lastname='User',
                     email='namee@organization.com',
                     description='User with custom role assigned',
                     role='bKrTCjFF9tKbaFk8',
                     user_type='Creator')

provider

Optional string. The provider for the account. The default value is arcgis. The other possible value is enterprise.

idp_username

Optional string. The name of the user as stored by the enterprise user store. This parameter is only required if the provider parameter is enterprise.

level

Optional string. The account level. (ArcGIS Enterprise prior to version 10.7) See http://server.arcgis.com/en/portal/latest/administer/linux/roles.htm

user_type

Required string. The account user type. This can be creator or viewer. The type effects what applications a user can use and what actions they can do in the organization. (ArcGIS Enterprise 10.7+ and ArcGIS Online) See http://server.arcgis.com/en/portal/latest/administer/linux/roles.htm

credits

Optional Float. The number of credits to assign a user. The default is None, which means unlimited. (ArcGIS Online only)

groups

Optional List. An array of Group objects to provide access to for a given user. (ArcGIS Enterprise 10.7+ and ArcGIS Online)

Returns

The user if successfully created, None if unsuccessful.

disable_users(users)

This is a bulk disables user operation that allows administrators to quickly disable large number of users in a single call. It is useful to do this operation if you have multiple users that need to be disabled. Supported on ArcGIS REST API 6.4+.

Argument

Description

users

Required List. List of User or UserNames to disable

Returns

Boolean

enable_users(users)

This is a bulk operation that allows administrators to quickly enable large number of users in a single call. It is useful to do this operation if you have multiple users that need to be enabled. Supported on ArcGIS REST API 6.4+.

Argument

Description

users

Required List. List of User or UserNames to enable

Returns

Boolean

get(username)

Returns the user object for the specified username.

Argument

Description

username

Required string. The user to get as a string. This can be the user’s login name or the user’s ID.

Returns

The user object if successfully found, None if unsuccessful.

property invitations

Provides access to invitations sent to users using the invite method

Note : this is only supported by ArcGIS Online

Returns

InvitationManager

invite(email, role='org_user', level=2, provider=None, must_approve=False, expiration='1 Day', validate_email=True)

Invites a user to an organization by email

Argument

Description

email

Required string. The user’s email that will be invited to the organization.

role

Optional string. The role for the user account. The default value is org_user. Other possible values are org_publisher, org_admin, org_viewer.

level

Optional string. The account level. The default is 2. See http://server.arcgis.com/en/portal/latest/administer/linux/roles.htm

provider

Optional string. The provider for the account. The default value is arcgis. The other possible value is enterprise.

must_approve

Optional boolean. After a user accepts the invite, if True, and administrator must approve of the individual joining the organization. The default is False.

expiration

Optional string. The default is ‘1 Day’. This is the time the emailed user has to accept the invitation request until it expires. The values are: 1 Day (default), 3 Days, 1 Week, or 2 Weeks.

validate_email

Optional boolean. If True (default) the Enterprise will ensure that the email is properly formatted. If false, no check will occur

Returns

boolean

property license_types

Returns a list of available licenses associated with a given GIS. The information returned can help administrators determine what type of a user should me based on the bundles associated with each user type.

This is only available on 10.7+.

Returns

list

property me

Gets the logged in user.

property roles

Helper object to manage custom roles for users. Returns an instance of the RoleManager

search(query=None, sort_field='username', sort_order='asc', max_users=100, outside_org=False, exclude_system=False, user_type=None, role=None)

Searches portal users.

Returns a list of users matching the specified query

Note

A few things that will be helpful to know.

  1. The query syntax has quite a few features that can’t be adequately described here. The query syntax is available in ArcGIS help. A short version of that URL is http://bitly.com/1fJ8q31.

  2. Searching without specifying a query parameter returns a list of all users in your organization.

  3. Most of the time when searching users you want to search within your organization in ArcGIS Online or within your Portal. As a convenience, the method automatically appends your organization id to the query by default. If you don’t want the API to append to your query set outside_org to True. If you use this feature with an OR clause such as field=x or field=y you should put this into parenthesis when using outside_org.

Argument

Description

query

Optional string. The query string. See notes above. Pass None to get list of all users in the organization.

sort_field

Optional string. Valid values can be username (the default) or created.

sort_order

Optional string. Valid values are asc (the default) or desc.

max_users

Optional integer. The maximum number of users to be returned. The default is 100.

outside_org

Optional boolean. This controls whether to search outside your organization. The default is False (search only within your organization).

exclude_system

Optional boolean. Controls if built-in system accounts are returned or not. True means built-in account are not returned, where as False means that they are.

user_type

Optional String. This parameters allows for the filtering of the users by their assigned type.

role

Optional String. Specify the roleId. This parameter allows for the filting of the users based on a roleId.

Returns

A list of users.

send_notification(users, subject, message, type='builtin', client_id=None)

Creates a user notifcations for a list of users.

Argument

Description

users

Required List. A list of strings or User objects to send notifcations to.

subject

Required String. The notifcation subject line.

message

Required String. The notifcation content. This should be in plain text.

type

Optional String. The notification can be sent various ways. These include:

  • builtin - The enterprise built-in system

  • push - The push notifcation to send a message to

  • email - a notification sent to the user’s email account

client_id

Optional String. The client id for push notification.

Returns

Boolean

signup(username, password, fullname, email)

Create a new user account in an ArcGIS Enterprise deployment.

Argument

Description

username

Required string. The desired username, which must be unique in the Portal, and at least 4 characters.

password

Required string. The passowrd, which must be at least 8 characters.

fullname

Required string. The full name of the user.

email

Required string. The email address for the user. This is important to have correct.

Returns

The user if successfully created, None if unsuccessful.

user_groups(users, max_results=- 1)

Givens a List of Users, the user_groups will report back all group ids that each user belongs to. This method is designed to be a reporting tool for administrators so they can easily manage a user or users groups.

property user_settings

Gets/sets the user’s settings

The user_settings allows administrators to set, and edit, new member defaults. Members who create their own built-in accounts and members added by an administrator or through automatic account creation will be automatically assigned the new member defaults.

Passing in None to the property will delete all the user settings.

Settings Key/Value Dictionary

Keys

Description

role

String/Role. The role ID. To assign a custom role as the new member default, provide a Role object.

Values: administrator, publisher, editor, viewer or custom Role object

userLicenseType

String. The ID of a user type licensed with your organization. To see which user types are included with your organization’s licensing, see the License resource in the Portal Admin API.

Values: creator, editor, Advanced GIS, Basic GIS, Standard GIS, viewer, or fieldWorker

groups

List of String/Groups. An array of group ID numbers or Group objects that specify the groups new members will be added to.

userType

String. This key only applies to ArcGIS Online. If new members will have Esri access (both) or if Esri access will be disabled (arcgisonly). The default value is arcgisonly.

Values: arcgisonly or both

apps

List of dictionaries. An array of an app’s itemID and, when applicable, entitlement. Example: {“apps” :[{“itemId”: “f761dd0f298944dcab22d1e888c60293”,”entitlements”: [“Insights”]}]}

appBundles

List of dictionaries. An array of an app bundle’s ID.

Example: {“appBundles”:[{“itemId”: “99d7956c7e824ff4ab27422e2a26c2b7}]}

Returns

Dictionary

GroupManager

class arcgis.gis.GroupManager(gis)

Bases: object

Helper class for managing GIS groups. This class is not created by users directly. An instance of this class, called ‘groups’, is available as a property of the Gis object. Users call methods on this ‘groups’ object to manipulate (create, get, search, etc) users.

create(title, tags, description=None, snippet=None, access='public', thumbnail=None, is_invitation_only=False, sort_field='avgRating', sort_order='desc', is_view_only=False, auto_join=False, provider_group_name=None, provider=None, max_file_size=None, users_update_items=False, display_settings=None, is_open_data=False, leaving_disallowed=False)

Creates a group with the values for any particular arguments that are specified. Only title and tags are required.

Argument

Description

title

Required string. The name of the group.

tags

Required string. A comma-delimited list of tags, or list of tags as strings.

description

Optional string. A detailed description of the group.

snippet

Optional string. A short snippet (<250 characters) that summarizes the group.

access

Optional string. Choices are private, public, or org.

thumbnail

Optional string. URL or file location to a group image.

is_invitation_only

Optional boolean. Defines whether users can join by request. Default is False meaning users can ask to join by request or join by invitation.

sort_field

Optional string. Specifies how shared items with the group are sorted.

sort_order

Optional string. Choices are asc or desc for ascending or descending, respectively.

is_view_only

Optional boolean. Defines whether the group is searchable. Default is False meaning the group is searchable.

auto_join

Optional boolean. Only applies to org accounts. If True, this group will allow joining without requesting membership approval. Default is False.

provider_group_name

Optional string. The name of the domain group.

provider

Optional string. Name of the provider.

max_file_size

Optional integer. This is the maximum file size allowed be uploaded/shared to a group. Default value is: 1024000

users_update_items

Optional boolean. Members can update all items in this group. Updates to an item can include changes to the item’s description, tags, metadata, as well as content. This option can’t be disabled once the group has been created. Default is False.

display_settings

Optional String. Defines the default display for the group page to show a certain type of items. The allowed values are: apps, all, files, maps, layers, scenes, tools. The default value is all.

is_open_data

Optional Boolean. Defines whether the group can be used in the Open Data capabilities of ArcGIS Hub. The default is False.

leaving_disallowed

Optional boolean. Defines whether users are restricted from choosing to leave the group. If True, only an administrator can remove them from the group. The default is False.

Returns

The group if successfully created, None if unsuccessful.

create_from_dict(dict)

Creates a group via a dictionary with the values for any particular arguments that are specified. Only title and tags are required.

Argument

Description

dict

Required dictionary. A dictionary of entries to create/define the group. See help of the create() method for parameters.

Returns

The group if successfully created, None if unsuccessful.

get(groupid)

Returns the group object for the specified groupid.

Argument

Description

groupid

Required string. The group identifier.

Returns

The group object if the group is found, None if it is not found.

search(query='', sort_field='title', sort_order='asc', max_groups=1000, outside_org=False, categories=None)

Searches for portal groups.

Note

A few things that will be helpful to know.

  1. The query syntax has many features that can’t

    be adequately described here. The query syntax is

    available in ArcGIS Help. A short version of that URL

    is http://bitly.com/1fJ8q31.

  2. Searching without specifying a query parameter returns a list of all groups in your organization.

  3. Most of the time when searching for groups, you’ll want to

    search within your organization in ArcGIS Online or within your Portal. As a convenience, the method automatically appends your organization id to the query by default. If you don’t want the API to append to your query set outside_org to True.

Argument

Description

query

Optional string on Portal, or required string for ArcGIS Online. If not specified, all groups will be searched. See notes above.

sort_field

Optional string. Valid values can be title, owner, created.

sort_order

Optional string. Valid values are asc or desc.

max_groups

Optional integer. Maximum number of groups returned, default is 1,000.

outside_org

Optional boolean. Controls whether to search outside your org. Default is False, do not search ourside your org.

categories

Optional string or list. A string of category values.

Returns

A list of groups matching the specified query.

GroupMigrationManager

class arcgis.gis.GroupMigrationManager(group)

Bases: object

This manager class allows groups to export and import data to and from EPK files.

create(items=None, future: bool = True)

Exports a Group content to a EPK Package Item.

EPK Items are intended to migrate content from an enterprise deployment to a new enterprise. Once an EPK Item is created using this method, you can use the load to ingest the package’s content into the target enterprise. If your package contains web maps, web-mapping applications, and/or associated web layers, during the import operation, the method will takes care of swizzling the service URLs and item IDs correctly.

There are some limits to this functionality. Packages should be under 10 GB in size and only hosted feature layers, web maps, web-mapping apps, and other text-based items are supported. You need to have administrative privileges to run this operation.

Argument

Description

items

Optional List<Item>. A set of items to export from the group. If nothing is given, all items will be attempted to be exported.

future

Optional Boolean. When True, the operation will return a Job object and return the results asynchronously.

Returns

Item –or– Job when future=True

inspect(epk_item) → dict

Returns the contents of the EPK Package

Keys

Description

epk_item

Required Item. A report on the content of the EPK Item. This allows administrators to view the contents inside a EPK.

Returns

dict

load(epk_item, item_ids: list = None, overwrite: bool = True, future: bool = True)

Imports the EPK content into the current Group.

Administrative privileges are required to run this operation. Once imported, items will be owned by the importer, and will have to be manually reassigned to the proper owner if needed.

Keys

Description

epk_item

Required Item. A report on the content of the EPK Item. This allows administrators to view the contents inside a EPK.

item_ids

Optional list. A list of item IDs to import to the organization.

overwrite

Optional bool. If the Items import exist, or the Item ID that is in use already, it will delete the old item and replace it with this one.

future

Optional bool. When True, the load will return a Job object and will not pause the current thread. When False load will occur in a synchronous fashion pausing the thread. If you are loading large amounts of data, set future to True to reduce time.

Returns

dict –or– Job when future=True

DatastoreManager

class arcgis.gis.DatastoreManager(gis, admin_url, server)

Bases: object

Helper class for managing the GIS data stores in ArcGIS Enterprise. This class is not created by users directly. Instances of this class are returned from arcgis.geoanalytics.get_datastores() and arcgis.raster.analytics.get_datastores() functions to get the corresponding datastores. Users call methods on this ‘datastores’ object to manage the datastores in a site federated with the Enterprise portal.

add(name, item)

Registers a new data item with the data store.

Argument

Description

name

Required string. The name of the item to be added on the server.

item

Required dictionary. The dictionary representing the data item. See https://developers.arcgis.com/rest/enterprise-administration/server/dataitem.htm

Returns

The new data item if registered successfully, None otherwise.

add_amazon_s3(name, bucket_name, access_key, access_secret, region, folder=None, default_protocal='https')

Allows administrators to registered Amazon S3 Buckets as Datastores.

Argument

Description

name

Required string. The name of the Amazon S3 instance.

bucket_name

Required String. The name of the S3 bucket.

access_key

Required String. The key value for the S3 Bucket.

access_secret

Required String. The access secret value for the S3 bucket.

region

Required String. The Amazon region as a string.

folder

Optional String. The S3 folder within the S3 Bucket.

default_protocal

Optional String. The URL scheme to contact the S3 bucket.

Returns

DataStore

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 azuredatalakestore, amazon, Alibaba, 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. Choice of “<shared|replicated|serverOnly>”, shared is the default.

Returns

The database if registered successfully, 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.

Returns

The folder if registered successfully, None otherwise.

add_ms_azure_storage(cloud_storage_name, account_key, account_name, container_name, folder=None)

Creates a cloud store for an Amazon or Microsoft Azure store.

Argument

Description

cloud_storage_name

Required string. The name of the storage entry.

access_key

Required String. The key value for the Azure storage.

access_secret

Required String. The access secret value for the Azure storage.

coontainer_name

Required String. The container holding the data.

folder

Optional String. The Azure folder within the datastore item.

Returns

DataStore

property config

Gets or sets the data store configuration properties, which affect the behavior of the data holdings of the server. The properties include: blockDataCopy. 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 Note: If you specify the property as True, users will not be able to publish geoprocessing services and geocode services from composite locators. These service types require data to be copied to the server. As a workaround, you can temporarily set the property to False, publish the service, and then set the property back to True.

get(path)

Returns the data item object at the given path.

Argument

Description

path

Required string. The path for the data item.

Returns

The data item object if found, None otherwise.

search(parent_path=None, ancestor_path=None, types=None, id=None)

You can use this operation to search through the various data items registered in the server’s data store. Searching without specifying the parent path and other parameters returns a list of all registered data items.

Argument

Description

parentPath

Optional string. The path of the parent under which to find items. Pass ‘/’ to get the root data items.

ancestorPath

Optional string. The path of the ancestor under which to find items.

types

Optional string. A comma separated filter for the type of the items. Types include folder, egdb, bigDataFileShare, datadir.

id

Optional string. A filter to search by the ID of the item.

Returns

A list of data items matching the specified query.

validate()

Validates all items in the datastore. In order for a data item to be registered and used successfully within the GIS’s data store, you need to make sure that the path (for file shares) or connection string (for databases) is accessible to every server node in the site. To validate all registered data items all at once, you can invoke this operation.

Returns

True if the data store items were validated, False if not.

RoleManager

class arcgis.gis.RoleManager(gis)

Bases: object

Helper class to manage custom roles for users in a GIS. Users don’t create this class directly. It is available as the roles property of the UserManager

# Usage Example

>>> role_mgr = gis.users.roles
>>> type(role_mgr)

<class 'arcgis.gis.RoleManager'>
all(max_roles=1000)

Provides a list containing the default Viewer and Data Editor roles, plus any custom roles defined in the GIS. (The org_admin, org_user, and org_publisher default roles are not returned. See Default roles for detailed descriptions of each role.)

Argument

Description

max_roles

Required integer. The maximum number of roles to be returned, defaults to 1000.

Returns

The list of all custom roles, plus the default Viewer and Data Editor roles defined in the GIS.

 # Usage Example

 >>> primary_default_roles = ['org_admin', 'org_publisher', 'org_user']

 >>> role_mgr = gis.users.roles
 >>> org_roles = role_mgr.all()

 >>> for role in org_roles:
     print(f"{role.name:25}{role.role_id}"

     Viewer                   iAAAAAAAAAAAAAAA
     Data Editor              iBBBBBBBBBBBBBBB
     Analyzer                 8KqWobO1p1vDLZ2O
     Sharing_analyst          ZllNulU2kqaFwsaH
     Group_creator            uT3334C4LtnQ99Cj

 >>> all_org_roles = primary_default_roles + [r.name for r in org_roles]
 >>> print(all_org_roles)

     ['org_admin', 'org_publisher', 'org_user', 'Viewer', 'Data Editor', 'Analyzer', 'Sharing_analyst', 'Group_creator']

See create method of UserManager for using role information when creating users.

create(name, description, privileges=None)

Creates a custom role with the specified parameters.

Argument

Description

name

Required string. The custom role’s name.

description

Required string. The custom role’s description.

privileges

Optional string. An array of strings with predefined permissions within each privilege. For supported privileges see https://developers.arcgis.com/rest/users-groups-and-items/privileges.htm

Returns

The custom role if successfully created, None if unsuccessful.

exists(role_name)

Checks to see if a role exists given the declared role name.

Argument

Description

role_name

Required string. The name of the role to determine if it exists or not.

Returns

True if the role exists, and False if it does not.

get_role(role_id)

Retrieves the role with the specified custom roleId.

Argument

Description

role_id

Required string. The role ID of the custom role to get.

Returns

The Role object associated with the specified role ID

ResourceManager

class arcgis.gis.ResourceManager(item, gis)

Bases: object

Helper class for managing resource files of an item. This class is not created by users directly. An instance of this class, called ‘resources’, is available as a property of the Item object. Users call methods on this ‘resources’ object to manage (add, remove, update, list, get) item resources.

add(file=None, folder_name=None, file_name=None, text=None, archive=False, access=None)

The add resources operation adds new file resources to an existing item. For example, an image that is used as custom logo for Report Template. All the files are added to ‘resources’ folder of the item. File resources use storage space from your quota and are scanned for viruses. The item size is updated to include the size of added resource files. Each file added should be no more than 25 Mb.

Supported item types that allow adding file resources are: Vector Tile Service, Vector Tile Package, Style, Code Attachment, Report Template, Web Mapping Application, Feature Service, Web Map, Statistical Data Collection, Scene Service, and Web Scene.

Supported file formats are: JSON, XML, TXT, PNG, JPEG, GIF, BMP, PDF, MP3, MP4, and ZIP. This operation is only available to the item owner and the organization administrator.

Argument

Description

file

Optional string. The path to the file that needs to be added.

folder_name

Optional string. Provide a folder name if the file has to be added to a folder under resources.

file_name

Optional string. The file name used to rename an existing file resource uploaded, or to be used together with text as file name for it.

text

Optional string. Text input to be added as a file resource, used together with file_name. If this resource is used, then file_name becomes required.

archive

Optional boolean. Default is False. If True, file resources added are extracted and files are uploaded to respective folders.

access

Optional String. Set file resource to be private regardless of the item access level, or revert it by setting it to inherit which makes the item resource have the same access as the item.

Supported values: private or inherit.

Returns

Python dictionary like the following if it succeeded: {

”success”: True, “itemId”: “<item id>”, “owner”: “<owner username>”, “folder”: “<folder id>”}

else like the following if it failed: {“error”: {

”code”: 400, “messageCode”: “CONT_0093”, “message”: “File type not allowed for addResources”, “details”: [] }}

export(save_path=None, file_name=None)

Export’s the data’s resources as a zip file

get(file, try_json=True, out_folder=None, out_file_name=None)

Gets a specific file resource of an existing item. This operation is only available to the item owner and the organization administrator.

Argument

Description

file

Required string. The path to the file to be downloaded. For files in the root, just specify the file name. For files in folders (prefixes), specify using the format <foldername>/<foldername>./../<filename>

try_json

Optional boolean. If True, will attempt to convert JSON files to Python dictionary objects. Default is True.

out_folder

Optional string. Specify the folder into which the file has to be saved. Default is user’s temporary directory.

out_file_name

Optional string. Specify the name to use when downloading the file. Default is the resource file’s name.

Returns

Path to the downloaded file if getting a binary file (like a jpeg or png file) or if try_jon = False when getting a JSON file.

If file is a JSON, returns as a Python dictionary.

list()

Provides a lists all file resources of an existing item. This resource is only available to the item owner and the organization administrator.

Returns

A Python list of dictionaries of the form: [

{

“resource”: “<resource1>”

}, {

”resource”: “<resource2>”

}, {

”resource”: “<resource3>”

}

]

remove(file=None)

Removes a single resource file or all resources. The item size is updated once resource files are deleted. This operation is only available to the item owner and the organization administrator.

Argument

Description

file

Optional string. The path to the file to be removed. For files in the root, just specify the file name. For files in folders (prefixes), specify using the format <foldername>/<foldername>./../<filename>

If not specified, all resource files will be removed.

Returns

If succeeded a boolean of True will be returned,

else a dictionary with error info {“error”: {“code”: 404,

”message”: “Resource does not exist or is inaccessible.”, “details”: []

}

}

update(file, folder_name=None, file_name=None, text=None)

The update resources operation allows you to update existing file resources of an item. File resources use storage space from your quota and are scanned for viruses. The item size is updated to include the size of updated resource files.

Supported file formats are: JSON, XML, TXT, PNG, JPEG, GIF, BMP, PDF, and ZIP. This operation is only available to the item owner and the organization administrator.

Argument

Description

file

Required string. The path to the file on disk to be used for overwriting an existing file resource.

folder_name

Optional string. Provide a folder name if the file resource being updated resides in a folder.

file_name

Optional string. The destination name for the file used to update an existing resource, or to be used together with the text parameter as file name for it.

For example, you can use fileName=banner.png to update an existing resource banner.png with a file called billboard.png without renaming the file locally.

text

Optional string. Text input to be added as a file resource, used together with file_name.

Returns

Python dictionary like the following if it succeeded: {

”success”: True, “itemId”: “<item id>”, “owner”: “<owner username>”, “folder”: “<folder id>” }

else like the following if it failed: {“error”: {

”code”: 404, “message”: “Resource does not exist or is inaccessible.”, “details”: [] } }

APIKeyManager

class arcgis.gis._impl.APIKeyManager(gis)

Bases: object

Creates, manages and updates API Keys for ArcGIS Online

create(title, tags, description=None, http_referers=None, redirect_uris=None, privileges=None)

Generates a new API Key for the Organization.

Parameter

Description

title

Required String. The name of the API Key Item.

tags

Required String. A comma seperated list of descriptive words describing the API Key item.

description

Optional String. A description of what the API Key is going to be used for.

http_referers

Optional List. A list of the http referrers for which usage of the API Key will be restricted to.

Example

` [ "https://foo.com", "https://bar.com" ] `

Note: Http Referrers can be configured for non apiKey type apps as well. The list configured here will be used to validate the app tokens sent in while accessing the sharing API. The referrer checks will not be applied to user tokens.

redirect_uris

Optional list. The URIs where the access_token or authorization code will be delivered upon successful authorization. The redirect_uri specified during authorization must match one of the registered URIs, otherwise authorization will be rejected.

A special value of urn:ietf:wg:oauth:2.0:oob can also be specified for authorization grants. This will result in the authorization code being delivered to a portal URL (/oauth2/approval). This value is typically used by apps that don’t have a web server or a custom URI scheme where the code can be delivered.

The value is a JSON string array.

Example:

privileges

Optional List. A list of the privileges that will be available for this API key.

Example

```

[ “portal:apikey:basemaps”, “portal:app:access:item:itemId”, “premium:user:geocode”, “premium:user:networkanalysis” ]

```

Note: Privileges can be configured for non API Key type apps as well. The list configured here will be used to grant access to items when item endpoint is accessed with app tokens. The checks will not be applied to user tokens and they can continue accessing items based on the current item sharing model. With app tokens, all items of app owner can be accessed if the privileges list is not configured.

Returns

APIKey

get(api_key)

Returns a Single API Key based on the Key Value

property keys

Returns a tuple of API Keys Registered with the Organization

Returns

tuple

validate(api_key, privileges=None)

Checks if an API has a specific privilege.

Parameter

Description

api_key

Required APIKey. The key to validate against.

privileges

Optional List. The list of the privileges to check for. The list consists of a list of string values.

Returns

bool

APIKey

class arcgis.gis._impl.APIKey(item, gis)

Bases: object

The APIKey is a single instance of a registered access key for performing certian operations based on permissions.

property apikey

Returns the API Key value for the current key.

Returns

String

delete()
property properties
reset()

Resets the API Key for the Item. The call will return the information with the new API Key information.

Returns

dict

update(http_referers=None, privileges=None)

Updates the API Key’s properties

Parameter

Description

http_referers

Optional List. A list of the http referrers for which usage of the API Key will be restricted to.

Example

` [ "https://foo.com", "https://bar.com" ] `

Note: Http Referrers can be configured for non apiKey type apps as well. The list configured here will be used to validate the app tokens sent in while accessing the sharing API. The referrer checks will not be applied to user tokens.

privileges

Optional List. A list of the privileges that will be available for this API key.

Example

```

[ “portal:apikey:basemaps”, “portal:app:access:item:itemId”, “premium:user:geocode”, “premium:user:networkanalysis” ]

```

Note: Privileges can be configured for non API Key type apps as well. The list configured here will be used to grant access to items when item endpoint is accessed with app tokens. The checks will not be applied to user tokens and they can continue accessing items based on the current item sharing model. With app tokens, all items of app owner can be accessed if the privileges list is not configured.

Returns

dict

ProfileManager

class arcgis.gis._impl._profile.ProfileManager

Bases: object

Allows for the controls and management of the profiles stored on the local operating system.

create(profile, url=None, username=None, password=None, key_file=None, cert_file=None, client_id=None)

Adds a new entry into the Profile Store.

Parameter

Description

profile

Required String. The name of the profile to add.

url

Optional String. The site url.

username

Optional String. The login user name.

password

Optional String. The login user password.

key_file

Optional String. The key file for PKI security.

cert_file

Optional String. The cert file for PKI security.

client_id

Optional String. The client ID for oauth login.

Returns

boolean

delete(profile)

Deletes a profile from the .arcgisprofile file

Parameter

Description

profile

Required String. The name of the profile to delete.

Returns

Boolean

get(profile)

Returns the profile information for a given entry.

Parameter

Description

profile

Required String. The name of the profile to get the information about.

Returns

Dict

list(as_df=False)

returns a list of profile names in the configuration file

Returns

List if as_df=False or Pandas DataFrame if as_df=True

save_as(profile, gis)

Saves and adds the provided GIS to the profile.

Parameter

Description

name

Required String. The name of the profile to save.

gis

Required GIS. The connection object to update the profile with.

Returns

Boolean

update(profile, url=None, username=None, password=None, key_file=None, cert_file=None, client_id=None)

Updates an existing profile in the credential manager.

Parameter

Description

profile

Required String. The name of the profile to update.

url

Optional String. The site url.

username

Optional String. The login user name.

password

Optional String. The login user password.

key_file

Optional String. The key file for PKI security.

cert_file

Optional String. The cert file for PKI security.

client_id

Optional String. The client ID for oauth login.

Returns

boolean

InvitationManager

class arcgis.gis._impl._invitations.InvitationManager(url, gis)

Bases: object

The InvitationManager provides functionality to see the existing invitations set out via email to your organization. The manager has the ability to delete any invitation sent out by an organization.

delete(invite_id)

deletes an invitation by ID

Returns

Boolean

get(invite_id)

Returns information about a single invitation

Returns

Dict

list()

Returns all the organizations invitations

Returns

List

CertificateManager

class arcgis.gis._impl.CertificateManager(gis)

Bases: object

The CertificateManager provides the administor the ability to register and unregister certficates with the GIS. This resource is available via HTTPS only.

add(name, domain, certificate)

The register HTTPS certificate operation allows administrator to register custom X.509 HTTPS certificates with their ArcGIS Online organizations. This will allow ArcGIS Online organization to trust the custom certificates used by a remote server when making HTTPS requests to it, i.e. store credentials required to access its resource and share with others.

A maximum of 5 certificates can be registered with an organization.

Parameter

Description

name

Required String. The certificate name.

domain

Required String. Server domain that the certificate is used for.

certificate

Required String. Base64-encoded certificate text, enclosed between —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—–.

Returns

Boolean

property certificates

Returns a list of certificates registered with the organization

Returns

List

delete(cert_id)

Unregisters the certificate from the organization

Parameter

Description

cert_id

Required String. The ID of the certificate to delete.

Returns

Boolean

get(cert_id)

Gets the certificate information for a single certificate

Parameter

Description

cert_id

Required String. The ID of the certificate to delete.

The dictionary contains the following information:

Key

Value

id

The ID of the registered certificate.

name

The certificate name.

domain

Server domain that the certificate is used for.

sslCertificate

Base64-encoded certificate text, enclosed between —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—–.

Returns

Dictionary (if found), else None

property properties

returns the properties of the resource

update(cert_id, name=None, domain=None, certificate=None)

The update HTTPS certificate operation allows organization administrators to update a registered custom X.509 HTTPS certificate.

Parameter

Description

cert_id

Required String. The ID of the certificate to delete.

name

Optional String. The certificate name.

domain

Optional String. Server domain that the certificate is used for.

certificate

Optional String. Base64-encoded certificate text, enclosed between —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—–.

Returns

Boolean

PortalDataStore

class arcgis.gis._impl._datastores.PortalDataStore(url, gis)

Bases: object

The datastores resource page provides access to operations that allow you to do the following:

  • Validate a data store against your server.

  • Register a data store to your server.

  • Retrieve a list of servers your data store is registered to.

  • Refresh your data store registration information in the server.

  • Unregister a data store from your server.

Additionally, users also have the ability to bulk publish layers from a data store, retrieve a list of previously published layers, and delete bulk-published layers.

delete_layers(item)

Before a data store can be unregistered from a server, all of its bulk-published layers must be deleted. The delete_layers removes all layers published from the data store.

Argument

Description

item

Required Item. The Data Store Item to delete all published layers.

Returns

Boolean

describe(item, server_id, path, store_type='datastore')

Describe data store is used to list the contents of a data store. A client can use it multiple times to discover the contents of the data store incrementally. For example, the client can request a description of the root, and then request sub-folders.

Argument

Description

item

Required Item. The Data Store Item to describe.

server_id

Optiona String. The unique id of the registered server.

path

Optional String. The path to examine the data in.

store_type

Optional String. For root resource the object type should be datastore, and for sub-folders, the object type should be listed as folder.

Returns

StatusJob

layers(item)

The layers operation returns a list of layers bulk published from a data store with the `publish_layers method. The layers method returns an array of tuples, with each tuple containing two objects: a layer and the dataset it was published from.

Argument

Description

item

Required Item. The Data Store Item to list all published layers and registered datasets.

Returns

List

property properties

returns the properties of the datastore

publish(config: dict, server_id, folder=None, description=None, tags: list = None)

The publish operation is used to publish scene layers by reference to data in a data store.

Argument

Description

config

Required Dictionary. This is the service configuration property and it must contain the reference to the data in the data store. It specifies the data store Id and the path of the data. A client can discover the proper paths of the data by using the describe method.

Example: {“type”:”SceneServer”,”serviceName”:”sonoma”,”properties”:{“pathInCachedStore”:”/v17_i3s/SONOMA_LiDAR.i3srest”,”cacheStoreId”:”d7b0722fb42c494392cb1845dacc00d9”}}

server_id

Required String. The unique Id of the server to publish to.

folder

Optional String. The name of the folder on server to place the service. If none is provided, it is placed in the root.

description

Optional String. An optional string to attached to the Item generated.

tags

Optional list. An array of descriptive words that describes the newly published dataset. This will be added to the Item

Returns

StatusJob

publish_layers(item, srv_config: dict, server_id, folder=None, server_folder=None, future=False)

The publish_layers operation publishes, or syncs, the datasets from a data store onto your ArcGIS Server, resulting in at least one layer per dataset.

When this operation is called for the first time, every parameter in the operation must be passed through. On subsequent calls, publish_layers will synchronize the datasets and created layers, which includes both publishing layers from new datasets and removing layers for datasets no longer found in the data store.

Argument

Description

item

Required Item. The Data Store Item to publish from.

srv_config

Required Dict. The JSON that will be used as a template for all the services that will be published or synced. This JSON can be used to change the properties of the data store’s map and feature services. Only map service configurations with feature services enabled are supported by this parameter.

server_id

Required String. The serverId that the datasets will be published to.

folder

Optional String. The folder to which the datasets will be published.

server_folder

Optional String. The name of the server folder.

future

Optional Boolean. If False, the value is returned, else a StatusJob is returned.

Returns

Boolean when future=False else a StatusJob

refresh_server(item, server_id)

After a data store has been registered, there may be times in which the data store’s registration information may be changed. When changes like these occur, the server will need to be updated with the newly configured information so that your users will still be able to access the data store items without interruption. The refresh_server can be called to propagate these changes to your ArcGIS Server. This operation can only be performed after the data store information has been updated.

Argument

Description

item

Required Item/Item Id (as string). The item Id or Item of the data store to register with the server. Note that a data store can be registered on multiple servers.

server_id

Required String. The unique id of the server you want to register the datastore with.

Returns

Boolean

register(item, server_id, bind=False)

The register method allows for Data Store type Items to be added to an ArcGIS Server instance. Before registering a data store, it is recommended that you validate your data store with the given server.

Argument

Description

item

Required Item/Item Id (as string). The item Id or Item of the data store to register with the server. Note that a data store can be registered on multiple servers.

server_id

Required String. The unique id of the server you want to register the datastore with.

bind

Optional Boolean. Specifies whether to bind the data store item to the federated server. For more information about binding a data store to additional federated servers, see Create a data store item for an existing registered data store. The default value is false.

Returns

Boolean

servers(item)

The servers property returns a list of your servers that a given data store has been registered to. This operation returns the serverId, the server name, both the server and admin URLs, and whether or not the server is hosted.

Argument

Description

item

Required Item. The Data Store Item to list all registered servers.

Returns

List

unregister(item, server_id)

Removes the datastore association from a server.

Returns

Boolean

validate(server_id, item=None, config=None, future=False)

The validate ensures that your ArcGIS Server can connect and use the datasets stored within a given data store. While this operation can be called before or after the data store has been registered with your server, it is recommended that the validate operation is performed beforehand. A data store can be validated by using either its datastoreId or the JSON for an unregistered data store.

Argument

Description

server_id

Required String. The unique id of the server you want to register the datastore with.

item

Optional Item/Item Id (as string). The item Id or Item of the data store to register with the server. Note that a data store can be registered on multiple servers.

config

Optional dict. The connection information for a new datastore.

Returns

Boolean