TileSharingDraft

Resumen

The TileSharingDraft class allows you to create a service definition draft file (.sddraft) for a web tile layer that copies all data to either ArcGIS Enterprise or ArcGIS Online.

Debate

To create the TileSharingDraft object, use the Map object's getWebLayerSharingDraft method and set the service_type parameter to TILE. The TileSharingDraft object can then be configured by setting service level properties and metadata properties.

Nota:

Si las propiedades de los metadatos (credits, description, summary, tags y useLimitations) no se establecen o constan de cadenas vacías, el elemento de la capa web obtendrá los metadatos del mapa o de la capa, dependiendo de lo que se comparta. Para obtener más información sobre la forma en que las capas web obtienen los metadatos, consulte Metadatos de la capa web.

After the TileSharingDraft object has been configured, it can be saved to a service definition draft file (.sddraft) using the exportToSDDraft method. 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 arcpy.sharing.

Code samples are available for the following:

Propiedades

PropiedadExplicaciónTipo de datos
cache.configuration
(Lectura y escritura)

The path and file name of a predefined tiling scheme .xml file generated by the Generate Map Server Cache Tiling Scheme tool.

String
cache.exportTiles
(Lectura y escritura)

Specifies whether clients will be allowed to download map tiles for offline use. The default value is False.

Boolean
cache.exportTilesCount
(Lectura y escritura)

The maximum number of tiles that can be downloaded in a single request. This property is only honored if the cache.exportTiles property is set to True. The default value is 100000.

Integer
credits
(Lectura y escritura)

The credits of the web layer.

String
description
(Lectura y escritura)

The description of the web layer.

String
offline
(Lectura y escritura)

Specifies whether a portal connection will be used. If set to False, you must be signed in to a portal to create a service definition draft file (.sddraft) using the exportToSDDraft method. If set to True, a service definition draft file can be created without being signed in to a portal.

Boolean
offlineTarget
(Lectura y escritura)

The target portal version to which the service definition will be published. Specifying a version ensures that the service definition contains content compatible with your portal. This property is only honored if the offline property is set to True.

  • ENTERPRISE_10x—Content will be compatible with ArcGIS Enterprise 10.9.1 or earlier. This is the default.
  • ENTERPRISE_11—Content will be compatible with ArcGIS Enterprise 11.0 or later.
  • ONLINE—Content will be compatible with ArcGIS Online.
String
portalFolder
(Lectura y escritura)

The name of the portal folder where the web layer will be published. The default folder is your root folder in My Content.

String
serverType
(Sólo lectura)

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 TileSharingDraft is HOSTING_SERVER. A serverType of HOSTING_SERVER indicates support for sharing to ArcGIS Enterprise or ArcGIS Online.

String
serviceName
(Lectura y escritura)

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.

String
sharing.groups
(Lectura y escritura)

The group names, separated by commas.

String
sharing.sharingLevel
(Lectura y escritura)

The sharing level of the web layer.

  • PROPIETARIO: solo el propietario (y los miembros de su organización con privilegios para visualizar contenido propiedad de otros miembros) pueden acceder al elemento.
  • ORGANIZACIÓN: comparta su contenido con todos los usuarios autenticados de la organización.
  • TODOS: comparta su contenido con el público. Cualquiera puede acceder a él y verlo.

String
summary
(Lectura y escritura)

The summary of the web layer.

String
tags
(Lectura y escritura)

The tags of the web layer. Multiple tags can be added or separated by a comma.

String
useLimitations
(Lectura y escritura)

The use limitations of the web layer.

String

Descripción general del método

MétodoExplicación
exportToSDDraft (out_sddraft)

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

Métodos

exportToSDDraft (out_sddraft)
ParámetroExplicaciónTipo de datos
out_sddraft

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

String

Once the TileSharingDraft 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.

Muestra de código

Publish a web tile layer to a portal folder

The following script creates a web tile layer service definition draft file (.sddraft) for a map and sets metadata properties. The web tile layer is published to a folder in either ArcGIS Enterprise or ArcGIS Online and shared with everyone (public). 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_name = "TileSharingDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

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

# Create TileSharingDraft and set metadata and portal folder properties
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "TILE", service_name)
sddraft.credits = "These are credits"
sddraft.description = "This is description"
sddraft.summary = "This is summary"
sddraft.tags = "tag1, tag2"
sddraft.useLimitations = "These are use limitations"
sddraft.portalFolder = "my folder name"
sddraft.sharing.sharingLevel = "EVERYONE"
sddraft.sharing.groups = ""  # Group names = "group1,group2"

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

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)

print("Finish Publishing")
Publish a cached web tile layer

The following script publishes a cached web tile layer by calling the Manage Map Server Cache Tiles tool to create cache tiles.

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_name = "TileSharingDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

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

# Create TileSharingDraft and set tiling scheme, export tile, and export tile count properties
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "TILE", service_name)
sddraft.cache.configuration = "C:\Program Files\ArcGIS\Pro\Resources\TilingSchemes\ArcGIS_Online_Bing_Maps_Google_Maps.xml"
sddraft.cache.exportTiles = True
sddraft.cache.exportTilesCount = 5566

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

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
results = arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)
rest_url = results[6]

# Manage Map Server Cache Tiles
# For cache, use multiple scales separated by semicolon (;)
# For example, "591657527.591555;295828763.795777"
arcpy.server.ManageMapServerCacheTiles(rest_url, "591657527.591555", "RECREATE_ALL_TILES")

print("Finish publishing")
Publish a list of layers

The following script publishes a list of layers from a map as a web tile 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_name = "TileSharingDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference layers to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps("World")[0]
lyrs = []
lyrs.append(m.listLayers('cities')[0])
lyrs.append(m.listLayers('counties')[0])

# Create TileSharingDraft and set metadata properties
sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "TILE", service_name, lyrs)
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
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, "My Hosted Services")

print("Finish Publishing")
Create and publish an offline service definition

The following script creates an offline service definition for the target portal version and publishes it as a web tile layer.

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "TileSharingDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

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

# Create TileSharingDraft and set offline and offlineTarget properties
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "TILE", service_name)
sddraft.offline = True
# Set offlineTarget property to "ONLINE" for ArcGIS Online or "ENTERPRISE_11" for ArcGIS Enterprise 11.0 or later
# The default is ArcGIS Enterprise 10.9.1 or earlier
sddraft.offlineTarget = "ENTERPRISE_10x"

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

# Sign in to portal to upload and publish
arcpy.SignInToPortal("https://portal.domain.com/webadaptor",
                     "MyUserName", "MyPassword")

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)

print("Finish Publishing")

Temas relacionados