Cognite Data Fusion CLI
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
To install the CDF CLI, you must first 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
To install the CDF CLI globally, run the following command from a terminal:
- npm
- Yarn
npm install --global @cognite/cdf-cli
yarn add --global @cognite/cdf-cli
Install the CDF CLI locally (JavaScript)
To install the CLI locally, run the following command from a terminal:
- npm
- Yarn
npm install @cognite/cdf-cli
yarn add @cognite/cdf-cli
Use the CDF CLI locally in a project
If you need to use the CLI in your project, add it within the
scripts
section in yourpackage.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.
Command | Alias | Description |
---|---|---|
signin [project] | login | Sign in to Cognite Data Fusion. |
data-models <command> | dm | Manage data models. |
signout | logout | Sign out of Cognite Data Fusion globally. |
status | Check user sign in status (status fails for signed-out users). |
Option | Type, default value | Description |
---|---|---|
-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]
Command | Description |
---|---|
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. |
Option | Type, default value | Description |
---|---|---|
-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. |
--tenant | [string] | The Azure AD tenant URI or ID. |
--cluster | [string][default:api] | The CDF cluster name. |
--devicecode | [boolean][default:false] | For interactive sign-in, 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>
Command | Alias | Description |
---|---|---|
data-models create | dm create | Create a data model. |
data-models publish | dm publish | Publish a data model. |
data-models generate | dm generate | Generate a GraphQL client code for the schema you provide by fetching the introspection query from the server. |
data-models delete | dm delete | Delete a data model. |
data-models list | dm list | List all data models. |
Option | Type, default value | Description |
---|---|---|
-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>
Command | Type, default value | Description |
---|---|---|
data-models create [name] | [string][required] | The name of the data model. |
Option | Type, default value | Description |
---|---|---|
-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
Command | Description |
---|---|
data-models publish | Updates a data model with a new GraphQL definition. |
Option | Type, default value | Description |
---|---|---|
-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
This is an irreversible action!
Command | Description |
---|---|
data-models delete | Deletes a data model. |
Option | Type, default value | Description |
---|---|---|
-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
Command | Description |
---|---|
data-models list | Lists all data models. |
Option | Type, default value | Description |
---|---|---|
-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
Command | Description |
---|---|
data-models delete | Generates a GraphQL client code. |
Option | Type, default value | Description |
---|---|---|
-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. Separate 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 isn't signed in.