Cognite Data Fusion CLI
The features described in this section are currently in beta testing and are subject to change.
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 v16 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
- pnpm
npm install --global @cognite/cdf-cli
yarn global add @cognite/cdf-cli
pnpm 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
- pnpm
npm install @cognite/cdf-cli
yarn add @cognite/cdf-cli
pnpm add @cognite/cdf-cli
You can also install the CLI globally and skip the project setup below with npm install -g @cognite/cdf-cli
or yarn global add @cognite/cdf-cli
Use the CDF CLI easily in a javascript project
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"
...
}
}
This will allow you to run npm run cdf
or yarn cdf
within your project.
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 to store and retrieve data. |
signout | logout | Sign out current user. |
status | Check if current user is signed in. |
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 Microsoft Entra ID 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 Microsoft Entra ID application. |
--client-secret | [string] | The client secret for the Microsoft Entra ID application generated by the user. Secrets have a long expiry and are suitable for CI/CD. |
--tenant | [string] | The Microsoft Entra ID 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. |
--space | [string] [default:"external-id"] | The space that the data model belongs in. Will create the space if it does not already exist |
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. |
--space | [string] [default:"external-id"] | The space that the data model belongs in. |
--version | [string] | Data model version in. |
--dry-run | [boolean] | Perform a dry run. Will only validate the data model without publishing. |
data-models delete
Use the data-models delete
command to delete the data model in CDF. The command will delete all unreferenced and unused data type within the data model.
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. |
--space | [string] [default:"external-id"] | The space that the data model belongs in. |
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. |
--space | [string] [default:"external-id"] | The space that the data model belongs in. |
--version | [string] | Data model version in. |
signout
Use the signout
command [alias:logout] to sign out the current user.
Usage: cdf signout
status
Use the status
command to check if the current user is signed in.
Usage: cdf status
The output fails if the user isn't signed in.