Skip to main content

Cognite Data Fusion (CDF) CLI

Beta

The features described in this section are currently in beta testing and are subject to change. We recommend that you don't use the features in production systems.

Use the Cognite Data Fusion (CDF) CLI to manage data models from the command line.

Install the CDF CLI

Prerequisites

To install the Cognite Data Fusion (CDF) CLI, you first need to install Node v14 or higher. For more information, see Node JS.

Follow the steps below to install the CDF CLI.

Install the CDF CLI globally

  1. To install the CDF CLI globally, run the following command from a terminal:

    npm install --global @cognite/cdf-cli

Install the CDF CLI locally (JavaScript)

  1. To install the CLI locally, run the following command from a terminal:

    npm install @cognite/cdf-cli

Use the CDF CLI locally in a project

  1. If you need to use the CLI in your project, add it within the scripts section in your package.json file.

    {
    "name": "xxx",
    ...
    "scripts":{
    ...
    "cdf": "cdf"
    ...
    }
    }

CDF CLI commands

Usage: cdf <command\> <subcommand\> [option]

To view available commands, enter cdf --help.

The tables below describe the available commands and options.

CommandAliasDescription
signin [project]loginSign in to Cognite Data Fusion.
data-models <command>dmManage data models.
signoutlogoutSign out of Cognite Data Fusion globally.
statusCheck user sign in status (status fails for signed-out users).
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--version[boolean]Show the version number.
--help[boolean]Show help.

signin

Use the signin command to sign in to a CDF project.

Usage: cdf signin [project]

CommandDescription
signin [project], [p]Specifies the CDF project to sign in to (supports Azure Active Directory currently) through interactive login or a client ID and client secret for machines.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.
--client-id[string]The client ID for the Azure AD application.
--client-secret[string]The client secret for the Azure AD application generated by the user. Secrets have a long expiry and are suitable for CI/CD.
--api-key[string]API key for legacy signin.
--tenant[string]The Azure AD tenant URI or ID.
--cluster[string][default:api]The CDF cluster name.
--devicecode[boolean][default:false]For interactive signin, shows a QR code to sign in. This is the recommended method for machines without a web browser.

data-models

Use that data-models command to create, publish, or delete a data model, retrieve data, and generate GraphQL code.

Usage: cdf data-models <command>

CommandAliasDescription
data-models createdm createCreate a data model.
data-models publishdm publishPublish a data model.
data-models generatedm generateGenerate a GraphQL client code for the schema you provide by fetching the introspection query from the server.
data-models deletedm deleteDelete a data model.
data-models listdm listList all data models.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--version[boolean]Show the version number.
--help[boolean]Show help.

data-models create

Use the data-models create command to create a data model in a CDF project.

Usage: cdf data-models create <name>

CommandType, default valueDescription
data-models create [name][string][required]The name of the data model.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.
--external-id[string][default:"name"]The external id of the data model.
--data-set-id[string]The client secret for the Azure AD application generated by the user. Secrets have a long expiry and are suitable for CI/CD.

data-models publish

Use the data-models publish command to update a data model with a new GraphQL definition. If there are any breaking changes, a new version of the data model is published. For non-breaking changes, the existing version of the data model is updated.

Usage: cdf data-models publish

CommandDescription
data-models publishUpdates a data model with a new GraphQL definition.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.
--external-id[string]The external id of the data model.
--file[string]The file containing the new GraphQL definition.
--allow-breaking-change[boolean][default:false]Allow for a breaking change, resulting in a new version of the data model.

data-models delete

Use the data-models delete command to delete the data model in CDF including all its data and versions.

Usage: cdf data-models delete

warning

This is an irreversible action!

CommandDescription
data-models deleteDeletes a data model.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.
--external-id[string]The external id of the data model.

data-models list

Use the data-models list command to list all data models in a CDF project.

In the terminal of your choice, enter the command below:

Usage: cdf data-models list

CommandDescription
data-models listLists all data models.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.

data-models generate

Use the data-models generate command to generate a GraphQL client code for the provided schema by fetching the introspection query from the server.

Usage: cdf data-models generate

CommandDescription
data-models deleteGenerates a GraphQL client code.
OptionType, default valueDescription
-v, --verbose[boolean][default:false]Show debug messages.
--interactive[boolean][default:true]Request for interactive input if any required field is missing from options.
--help[boolean]Show help.
--external-id[string]The external id of the data model.
--plugins[array]["typescript", "typescript-operations", "typescript-resolvers", "typescript-react-apollo", "typescript-apollo-angular"]The code generation plugin. Separete multiple plugins with a space.
--operations-files[string][default:"src/operations.graphql"]The file path to scan for GraphQL code.
--output-file, -f[string][default:"generated-types.ts"]The file name of the generated code.

signout

Use the signout command [alias:logout] to sign out from CDF globally.

Usage: cdf signout

status

Use the status command to check the sign-in status.

Usage: cdf status

The output fails if the user is not signed in.