# Apply Project Tags

### How It Works

```bash
$ npm run start -- apply-tags -h
Usage: robosaur apply-tags [options] <configFile>

Applies tags to projects based on the given config file

Options:
  -h, --help  display help for command
```

* Robosaur will try to apply tags to projects specified in the config file's payload, or from a separate CSV file. The CSV file can be located on your local drive or one of our supported cloud object storage.
* If the tag in the config file is not present in the team, Robosaur will create the tag and apply it to the project automatically.
* The behavior will be depended by the `applyTags` attribute on the configuration file.

### Payload

#### JSON Format

```json
{
  ...
  "applyTags": {
    "teamId": "<TEAM_ID>",
    "source": "inline",
    "payload": [
      {
        "projectId": "<PROJECT_ID_1>",
        "tags": ["<TAG_1>", "<TAG_2>"]
      },
      {
        "projectId": "<PROJECT_ID_2>",
        "tags": ["<TAG_3>"]
      }
    ]
  }
  ...
}
```

#### CSV Format

Can works for all object storage methods. Robosaur will tag a project with multiple tags if there are multiple tags present in the `tags` column in the csv file. Please use a comma \[`,`] as a delimiter to apply multiple tags for a project.

```
tags,projectId
"<TAG_1>,<TAG_4>",<PROJECT_ID_1>
<TAG_2>,<PROJECT_ID_1>
<TAG_3>,<PROJECT_ID_2>
```

### Object Storage

Same as any other features, it could support multiple methods, e.g. inline, local filesystem, and cloud object storage. For more detailed information, please refer to [this page](https://docs.datasaur.ai/integrations/robosaur/storage-options).

#### Using Local File Example

```json
{
  ...
  "applyTags": {
    "teamId": "<TEAM_ID>",
    "source": "local",
    "path": "<path/to/csv/file>"
  }
  ...
}
```

#### Using Cloud Object Storage Example

```json
{
  ...
  "credentials": {
    ...
  },
  "applyTags": {
    "teamId": "<TEAM_ID>",
    "source": "s3 | gcs | azure",
    "bucketName": "<BUCKET_NAME>",
    "path": "<path/to/csv/file/on/bucket>",
  }
  ...
}
```
