Custom Data CLI Reference

This topic discusses the Custom Data Feeds (CDF) command line tool in more detail.

Summary

The CDF command line tool has seven commands, which are described in the following table:

CommandDescription
cdf createapp <name>Create a new custom data app
cdf createprovider <name>Create a new custom data provider
cdf export <name>Export a custom data provider into a package file
cdf deleteprovider <name>Delete a provider from a custom data app
cdf listprovidersList all the providers registered in a custom data app
cdf register <name> <server-admin-url> <token>Register a provider with ArcGIS Server and optionally create a feature service
cdf unregister <name> <server-admin-url> <token>Unregister a provider with ArcGIS Server and optionally delete any associated feature services

The syntax for the cdf command is cdf <command> [options].

Create a New Custom Data App

Use the command cdf createapp <name> to create a new custom data app. This command creates a Node.js project with the following directory structure in the current directory.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
    - config/
        | default.json
    - framework/
    - node_modules/
    - src/
        - request-handlers/
            | welcome-page.js
        | index.js
        | plugins.js
        | routes.js
    - cdconfig.json
    - package-lock.json
    - package.json

Since the cdf createapp command generates several files, it may take several minutes to complete.

Create a New Custom Data Provider

Use the cdf createprovider <name> command to create a new custom data provider. You must run the command at the root of the custom data app directory. The command creates a project in the providers folder of the custom data app. If the providers folder is missing, the command will automatically create it. The providers directory will have the following structure:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
    -providername
        - config/
            | default.json
        - node_modules/
        - src/
            | index.js
            | model.js
        - test/
            | index.test.js
            | model.test.js
        - cdconfig.json
        - package-lock.json
        - package.json

This folder structure serves as a template for creating a custom provider. Each time you create a new provider, a new project directory named for the new provider will be created in the providers folder.

Export Custom Data Provider

Use the cdf export <name> command to export a data provider to a custom data package file (.cdpk) after you have written and tested your custom data provider code. You must run the command at the root of the custom data app directory. The resulting .cdpk file is used to register the custom data provider with ArcGIS Server. Any existing provider .cdpk with the same name will be overwritten.

Delete a Provider

Use the cdf deleteprovider <name> command to delete a custom data provider. You must run the command at the root of the custom data app directory. This is the recommended method for removing a provider project from your provider directory. Do not simply delete the provider project manually.

List Registered Providers

Use the cdf listproviders command at the root of a custom app directory to list all providers registered with the app.

Register a Provider

The cdf register command is a multi-functional command that will export the .cdpk, upload the .cdpk, register the custom data provider, and optionally create a service connected to the provider. The register command also doubles as a way to update a registered custom data provider. Using the register command with a provider of the same name will update/overwrite the registered provider on ArcGIS Server. Because this command requires the use of administrative APIs, either a valid ArcGIS Portal or ArcGIS Server token is required. The positional arguments and options for the command are listed below.

PositionalDescriptionUsage
nameName of the custom data providerRequired
server-admin-urlURL for the ArcGIS ServerRequired
tokenServer or Portal token issued to a user with permission to use Admin APIsRequired
OptionDescriptionUsage
--ud, --upload-descriptionText that describes the uploaded providerAlways optional
-s, --service-nameName for the service that is linked to the provider. Including this option signifies the intention to create a service.Required if creating a service
--sd, --service-descriptionText that describes the created serviceAlways optional
--hostValue for the hosts parameter in the service pathRequired if creating a service and the provider uses the hosts parameter
--idValue for the id parameter in the service pathRequired if creating a service and the provider uses the id parameter

Example usage:

  1. Register a provider

    cdf register <name> <server-admin-url> <token>

  2. Create a service that uses both path parameters with no descriptions

    cdf register <name> <server-admin-url> <token> -s "my-service" --host "foo" --id "bar"

  3. Create a service that uses both path parameters with full descriptions

    cdf register <name> <server-admin-url> <token> --ud "Description of uploaded .cdpk" -s "my-service" --sd "Description of my service" --host "foo" --id "bar"

ArcGIS Server or Portal tokens may occassionally begin with a hyphen "-" character, and wrapping the token positional in quotations will be necessary.

For Powershell: cdf register <provider> <server url> \`"-token\`" (slash, backtick, double quotation)

For GitBash: cdf register <provider> <server url> \"-token\" (slash, double quotation)

Unregister a Provider

The cdf unregister command is a multi-functional command that will unregister a custom data provider and optionally delete services that are connected to the provider. Because this command requires the use of administrative APIs, either a valid ArcGIS Portal or ArcGIS Server token is required. The positional arguments and options for the command are listed below.

PositionalDescriptionUsage
nameName of the custom data providerRequired
server-admin-urlURL for the ArcGIS ServerRequired
tokenServer or Portal token issued to a user with permission to use Admin APIsRequired
OptionDescriptionUsage
-d, --delete-servicesDelete all services that use this providerAlways optional

Example usage:

  1. Unregister a provider

    cdf unregister <name> <server-admin-url> <token>

  2. Unregister provider and delete all associated services

    cdf unregister <name> <server-admin-url> <token> --delete-services

ArcGIS Server or Portal tokens may occassionally begin with a hyphen "-" character, and wrapping the token positional in quotations will be necessary.

For Powershell: cdf unregister <provider> <server url> \`"-token\`" (slash, backtick, double quotation)

For GitBash: cdf unregister <provider> <server url> \"-token\" (slash, double quotation)

Start the CDF Service Locally

Start the custom data feeds service locally using npm start. The following options are available:

OptionDescriptionUsage
--portProvide a port number. e.g. 8081Always optional
--self-signed-certCreates a self-signed cert to start the CDF development server on HTTPSAlways optional

Example usage:

npm start -- --port 8081 --self-signed-cert

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.