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.
Depending on whether you're creating a sharing draft for a web layer, web tool, or service, use the following functions:
- 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.
The tables below describe the sharing classes and functions.
Sharing classes
Class | Description |
---|---|
Creates a sharing draft for a hosted web feature layer or a hosted table. | |
Creates a sharing draft for a web tool on an ArcGIS Enterprise portal or a geoprocessing service on a stand-alone server. | |
Creates a sharing draft for a map image layer with an optional web feature layer on a federated server. | |
Creates a sharing draft for a map service on a stand-alone server. | |
Creates a sharing draft for a web scene layer with an associated web feature layer. | |
Creates a sharing draft for a web tile layer. |
Sharing functions
Function | Description |
---|---|
Creates a MapServiceDraft or GeoprocessingSharingDraft sharing draft class. | |
Publishes a SceneLayerSharingDraft object as a web scene layer with an associated web feature layer to ArcGIS Online or ArcGIS Enterprise. |
The sharing draft classes contain the most common web layer, web tool, map service, and geoprocessing service properties. After configuring properties on the sharing draft object, the subsequent steps differ based on the type of sharing class.
The sharing draft classes FeatureSharingDraft, TileSharingDraft, MapImageSharingDraft, MapServiceDraft, and GeoprocessingSharingDraft can be configured and saved as a service definition draft file (.sddraft) using the exportToSDDraft method. Once the .sddraft file is created, it can be converted into a fully consolidated service definition file (.sd) using the Stage Service tool. This process compiles all necessary information to publish the GIS resource. Additionally, the Stage Service tool analyzes the .sddraft file for suitability and identifies potential performance issues before converting it to a .sd file. The .sd 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.
The sharing draft class SceneLayerSharingDraft follows a different workflow compared to the other sharing draft classes. After configuring the draft, use the analyzeForSharing method to analyze the SceneLayerSharingDraft object for errors and warnings. The object can then be published as a web scene layer with an associated web feature layer to ArcGIS Online or ArcGIS Enterprise using the Publish function.