# Onsearch CLI

## Login

COMMAND : `onsearch login`

Description : Interactive login via token. It will open browser and from your browser you have to copy token and paste in CLI.

Sucess response 

``` json
Login success
```

## Getting current logged in user info

COMMAND : `onsearch me`

Description : Getting current logged in user info

Success response  

``` json
{
  "me": {
    "name": "John Doe",
    "createdAt": "1597993378183",
    "email": "johndoe@gmail.com",
    "firebaseId": "firebase_id",
    "id": "id",
    "profilePictureUrl": null,
    "updatedAt": "1597993407247"
  }
}
```

## Projects list

COMMAND : `onsearch projects list`

Description : Getting list of projects for current logged in user.

Success Response 

``` json
{
  "projects": [
    {
      "name": "test project",
      "id": "5f3f71aeddd952003fef6ddf",
      "active": true,
      "archived": false,
      "createdAt": "1597993390864",
      "updatedAt": "1598244282582"
    },
  ]
}
```

## Create project

COMMAND : `onsearch projects create`

Params :

| Short flag | Long flag      | Default | Description         |
|------------|----------------|---------|---------------------|
| -n         | --project_name |         | Name of the project |

Success response

```json
{
  "createProject": {
    "project": {
      "name": "demoproject",
      "id": "project_id",
      "active": true,
      "archived": false,
      "createdAt": "1598248018190",
      "updatedAt": "1598248018190"
    }
  }
}
```

## Project by id

COMMAND : `onsearch project`

Params : 

| Short flag | Long flag | Default | Description       |
|------------|-----------|---------|-------------------|
| -i         | --id      |         | Id of the project |

Success response

```json
{
    "project": {
        "name": "demoproject",
        "id": "project_id",
        "active": true,
        "archived": false,
        "createdAt": "1598248018190",
        "updatedAt": "1598248018190"
    }
}
```

## Models list

COMMAND : `onsearch models list`

Description : Get list of models

Params : 

| Short flag | Long flag     | Default | Description             |
|------------|---------------|---------|-------------------------|
| -p         | --project_id  |         | Id of the project       |
| -i         | --interactive |         | Enable interactive mode |


Success response

```json
[
  {
    "cpu": 1,
    "id": "id",
    "name": "testmodal",
    "ram": 1,
    "status": "created"
  },
  {
    "cpu": 1,
    "id": "id",
    "name": "testmodal",
    "ram": 1,
    "status": "created"
  },
]
```

## Model create

COMMAND : `onsearch models create`

Description : Create model

Params : 

| Short flag | Long flag     | Default | Description             |
|------------|---------------|---------|-------------------------|
| -c         | --cpu         | 1       | CPU for the model       |
| -m         | --model_name  |         | Name of model           |
| -r         | --ram         | 1       | Ram for the model       |
| -p         | --project_id  |         | Project id              |
| -i         | --interactive |         | Enable interactive mode |


## Collection list

COMMAND : `onsearch collections list`

Description : List all the collection from particular project

Params : 

| Short flag | Long flag     | Default | Description             |
|------------|---------------|---------|-------------------------|
| -p         | --project_id  |         | Project id              |
| -i         | --interactive |         | Enable interactive mode |

Success response :

```json
[
  {
    "archived": false,
    "changed": false,
    "changedAt": "1598244269489",
    "encodedAt": "1598244282582",
    "encoding": false,
    "encodingAt": "1598244278361",
    "id": "id",
    "index":"index_id",
    "searchableFields": [  ],
    "syncAt": null,
    "syncedAt": "1598244208826",
    "syncing": false,
    "syncingAt": "1598244208183",
    "name": "My First Collection"
  }
]
```

## Collection create

COMMAND : `onsearch collections create`

Description : Create collection

Params : 

| Short flag | Long flag         | Default | Description             |
|------------|-------------------|---------|-------------------------|
| -p         | --project_id      |         | Project id              |
| -c         | --collection_name |         | Collectio name          |
| -i         | --interactive     |         | Enable interactive mode |

Success response :

```json
{
  "archived": false,
  "changed": false,
  "changedAt": null,
  "encodedAt": null,
  "encoding": false,
  "encodingAt": null,
  "id": "ec4dfabc-eeeb-40f5-9018-843f7b726549",
  "index": null,
  "searchableFields": [],
  "syncAt": null,
  "syncedAt": null,
  "syncing": false,
  "syncingAt": null,
  "name": "testcollection"
}
```
