Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding j1 CLI documentation. #727

Merged
merged 2 commits into from
Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/integrations/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -1526,3 +1526,63 @@ immediately reflect that in the graph.
We hope to provide a good interface via this SDK for providing an interface for
handling events via this SDK and providing commands/utilities for testing events
to get an understanding of how they may affect the JupiterOne graph.

## j1 CLI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to start on line 1490 with the other j1 cli info. Up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I went back and forth with putting it higher up starting at line 1490. My main reason for leaving it at the bottom is it felt like it was interrupting the j1-integration documentation too much when placed up there.

I'll leave it where it is for now, but we can move it if we start to see its location confusing people.


In addition to the `j1-integration` CLI, this project exposes a `j1` CLI for
`import` and `export` processes.

### Authentication

For commands that require interaction with JupiterOne's API, the CLI will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For commands that require interaction with JupiterOne's API, the CLI
provides two options for providing credentials:

  1. All commands that interact with an API will accept an --api-key option.
  2. For added convenience when developing locally, we will also look for a
    JUPITERONE_API_KEY environment variable to be used as the API key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually copied this from the Authentication of j1-integration since they work the exact same way, but I agree that your wording is better.

provide ways of inputing credentials. To support that, all commands that
interact with an API will accept an `--api-key` option.

For convenience when developing locally, we will also look for a
`JUPITERONE_API_KEY` environment variable for an API key to use.

### Supported commands

Currently, the CLI supports a limited interface consisting of only two commands:
`export` and `import`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to include the required options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required is a bit odd for these, since so many of them either have a default or will use .env values if provided that way.

I think the only option truly flagged as a required one is the scope for the import command. I can get that added in a later PR

#### Command `j1 export`

```
Usage: j1 export [options]

Exports account's entities/relationships into csv files

Options:
-d, --data-dir <relative_directory> The directory where entities/relationships will be downloaded (default: ".j1/export")
--account <account> The JupiterOne account you are exporting entities/relationships from
--api-key <key> The key used to initiate api calls with your instance of JupiterOne
--include-entities Include entities in export (default: true)
--include-relationships Include relationships in export (default: true)
--include-deleted Include deleted entities/relationships in export (default: true)
--no-include-entities Exclude entities in export
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to change --no-include-entities to --exclude-entities one day

--no-include-relationships Exclude relationships in export
--no-include-deleted Exclude deleted entities/relationships in export
--api-base-url <url> The base URL used to initiate api calls with your instance of JupiterOne (defaults to `https://api.us.jupiterone.io`)
-h, --help display help for command
```

#### Command `j1 import`

```
Usage: j1 import [options]

Imports exported account entities/relationships into JupiterOne account
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any gotchas that we should make the user aware of? For example, what if a _key already exists?


Options:
-d --data-dir <relative_directory> The directory where entities and relationships can be found (default: ".j1/export")
--scope <scope> A unique id that identifies the synchronization job that will be importing your assets, use any id of your choosing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the default for scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No default. It will error if one isn't provided.

--account <account> The JupiterOne account you are importing entities/relationships into
--api-key <key> The key used to initiate api calls with your instance of JupiterOne
--include-relationships Include relationships in import (default: true)
--include-deleted Include deleted entities/relationships in import (default: true)
--no-include-entities Exclude entities in import
--no-include-relationships Exclude relationships in import
--api-base-url <url> The base URL used to initiate api calls with your instance of JupiterOne (defaults to `https://api.us.jupiterone.io`)
-h, --help display help for command
```