FeatureSharingDraft

Zusammenfassung

The FeatureSharingDraft class allows you to configure web feature layer properties and create a service definition draft (.sddraft) file, which can then be shared to either ArcGIS Enterprise or ArcGIS Online.

Auswertung

To create the FeatureSharingDraft class object, use the map class function getWebLayerSharingDraft and set the service_type parameter to FEATURE. The FeatureSharingDraft class object can then be configured by setting service level properties. After the FeatureSharingDraft class object has been configured, it can then be saved to a service definition draft (.sddraft) file using the exportToSDDraft function. It can then be staged and shared to either ArcGIS Enterprise or ArcGIS Online using the Stage Service and Upload Service Definition tools. For more information, see Introduction to the sharing module.

Eigenschaften

EigenschaftErklärungDatentyp
allowExporting
(Lesen und schreiben)

A Boolean that determines if users can export the web layer to different formats.

Boolean
credits
(Lesen und schreiben)

A string that represents the credits.

String
description
(Lesen und schreiben)

A string that represents the description.

String
offline
(Lesen und schreiben)

A Boolean that determines whether to use a portal connection or not. If offline is set to False, you must be signed in to a portal in order to create a service definition draft (.sddraft) file using the exportToSDDraft function. If offline is set to True, a service definition draft file can be created without being signed in to a portal.

Boolean
overwriteExistingService
(Lesen und schreiben)

A Boolean that determines whether to overwrite an existing web layer or not.

Boolean
portalFolder
(Lesen und schreiben)

A string that represents the name of a portal folder to which you want to publish the web layer. The default folder is your root folder in My Content.

String
serverType
(Nur lesen)

Returns a string representing the server type as specified when the sharing draft was created from the getWebLayerSharingDraft function from the map class. The only possible value returned from serverType for a FeatureSharingDraft is HOSTING_SERVER. A serverType of HOSTING_SERVER indicates support for sharing to ArcGIS Enterprise or ArcGIS Online.

String
serviceName
(Lesen und schreiben)

A string that represents the name of the web layer. This is the name people will see and use to identify the web layer. The name can only contain alphanumeric characters and underscores. No spaces or special characters are allowed. The name cannot be more than 120 characters in length.

String
summary
(Lesen und schreiben)

A string that represents the summary.

String
tags
(Lesen und schreiben)

A string that represents the tags. Multiple tags can be added or separated by a comma or semicolon.

String
useLimitations
(Lesen und schreiben)

A string that represents the use limitations.

String

Methodenübersicht

MethodeErklärung
exportToSDDraft (out_sddraft)

Converts a FeatureSharingDraft to a service definition draft (.sddraft) file.

Methoden

exportToSDDraft (out_sddraft)
ParameterErklärungDatentyp
out_sddraft

A string that represents the path and file name for the output service definition draft (.sddraft) file.

String

Once the FeatureSharingDraft has been configured, it can then be saved as a service definition draft (.sddraft) file. It can then be staged and shared to either ArcGIS Enterprise or ArcGIS Online using the Stage Service and Upload Service Definition tools.

Codebeispiel

The following script publishes a map as a web feature layer to either ArcGIS Enterprise or ArcGIS Online. Portal information is obtained from the SignInToPortal function.

import arcpy
import os

# Sign in to portal
arcpy.SignInToPortal('https://www.arcgis.com', 'MyUserName', 'MyPassword')

# Set output file names
outdir = r"C:\Project\Output"
service = "FeatureSharingDraftExample"
sddraft_filename = service + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps("World")[0]

# Create FeatureSharingDraft and set service properties
sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service)
sharing_draft.summary = "My Summary"
sharing_draft.tags = "My Tags"
sharing_draft.description = "My Description"
sharing_draft.credits = "My Credits"
sharing_draft.useLimitations = "My Use Limitations"

# Create Service Definition Draft file
sharing_draft.exportToSDDraft(sddraft_output_filename)

# Stage Service
sd_filename = service + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(sd_output_filename, "My Hosted Services")

print("Successfully Uploaded service.")