Introduction to arcpy.sharing

The Sharing module, arcpy.sharing, is a Python module that allows you to automate sharing workflows. Use it to create a sharing draft, which is a configurable set of properties for a web layer, web tool, map service, or geoprocessing service. Creating a sharing draft is the first step in automating the sharing of a GIS resource to ArcGIS Enterprise, ArcGIS Online, or ArcGIS Server.

  • To create the sharing draft for a web layer on ArcGIS Enterprise or ArcGIS Online from a map in an ArcGIS Pro project, use the getWebLayerSharingDraft function from the Map class.
  • To create the sharing draft for a web tool on an ArcGIS Enterprise portal, or a map service or geoprocessing service on a stand-alone ArcGIS Server site, use the CreateSharingDraft function.

Sharing classes are as follows:

ClassDescription
FeatureSharingDraft

Creates a sharing draft for a hosted web feature layer

GeoprocessingSharingDraft

Creates a sharing draft for a web tool on an ArcGIS Enterprise portal or a geoprocessing service on a stand-alone server

MapImageSharingDraft

Creates a sharing draft for a map image layer with an optional web feature layer on a federated server

MapServiceDraft

Creates a sharing draft for a map service on a stand-alone server

TileSharingDraft

Creates a sharing draft for a web tile layer

The sharing draft classes contain the most common web layer, web tool, map service, and geoprocessing service properties. Additional properties can be customized in the service definition draft file using standard third-party XML editors or modified using XML Python libraries such as the xml.dom.minidom library. For example, feature access can be enabled on a map image layer or map service. See MapImageSharingDraft and MapServiceDraft for code samples.

After the sharing draft has been configured, it can be saved to a service definition draft file (.sddraft) using the exportToSDDraft function from the FeatureSharingDraft, TileSharingDraft, MapImageSharingDraft, MapServiceDraft, or GeoprocessingSharingDraft classes.

Once the service definition draft has been created, it can be converted to a fully consolidated service definition file (.sd) using the Stage Service tool. Staging compiles all the necessary information to successfully publish the GIS resource. The Stage Service tool will also analyze service definition draft files to determine suitability and sources of potential performance issues before converting a service definition draft file to a service definition file.

The service definition file can then be uploaded and published as a GIS service to a server federated with ArcGIS Enterprise, a stand-alone ArcGIS Server site, or ArcGIS Online using the Upload Service Definition tool. When the service is published to ArcGIS Enterprise or ArcGIS Online, a corresponding web layer is automatically created.

Heredado:

The arcpy.sharing module was introduced at ArcGIS Pro 2.2 to provide a better experience when sharing web layers than the original function, CreateWebLayerSDDraft. The original function is provided for backward compatibility only.

Temas relacionados