# apollo-delphi-migration

## Make commands
- `make venv` - create local virtual env
- `make test` - run tests
- `make lint` - run pylint check
- `make clean` - clean unnecessary files
- `make docker/login` - aws configuration need to be set first
- `make docker/build` - build Docker images from a Dockerfile
- `make docker/push` - push an image to a registry

> When run `make test`, `make lint`  command, all dependencies from requirements/test will be installed.

> When run `make venv` base.pip dependencies will be installed

## CLI Arguments

| key                               | required? | description                                                    | supported values                                                                                                                                                                | default |
|-----------------------------------|-----------|----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `--src-bucket`                    | true      | Source bucket                                                  |                                                                                                                                                                                 |         |
| `--dst-bucket`                    | true      | Destination bucket                                             |                                                                                                                                                                                 |         |
| `--dsp`                           | true      | DSP                                                            | `apple`, `spitify`                                                                                                                                                              |         |
| `--report-type`                   | false     | Report type                                                    | Spotify: `streams`, `users`, `tracks`, `sub_30_sec_streams`. Apple: `amStreams`, `amContent`, `amEvent`, `amContentDemographics`, `amArtistDemographics`, `amNonRoyaltyStreams` |         |
| `--licensor`                      | false     | Licensor                                                       | `sony`, `smej`, `smejintl`, `theorchard`                                                                                                                                        |         |
| `--start-date`                    | true      | Start date. Supported format `YYYY-MM-DD`.                     |                                                                                                                                                                                 |         |
| `--end-date`                      | false     | End date Supported format `YYYY-MM-DD`(exclusive).             |                                                                                                                                                                                 | TODAY   |
| `--log-level`                     | false     | Application logging level.                                     | `FATAL`, `ERROR`, `WARN`, `INFO`, `DEBUG`                                                                                                                                       | INFO    |
| `--with-fingerprint-tagging`      | false     | Enables destination object tagging with fingerprint.           | N/A                                                                                                                                                                             | N/A     |
| `--with-fingerprint-validation`   | false     | Enables destination and source object fingerprint validation.  | N/A                                                                                                                                                                             | N/A     |
| `--no-copy`                       | false     | Execution without copying data. Useful for tagging/validation. | N/A                                                                                                                                                                             | N/A     |

> **Note.** Usage of `--with-fingerprint-tagging` or `--with-fingerprint-validation` will cause to significant performance degradation.

## Run With Docker

Configure your AWS credentials:
```bash
$ export AWS_ACCESS_KEY_ID=<YOUR AWS ACCESS KEY>
$ export AWS_SECRET_ACCESS_KEY=<YOUR AWS SECRET ACCESS KEY>
```

Use following command to run the tool using options listed above:
```bash
$ docker run --rm -it \
    -e AWS_ACCESS_KEY_ID=<YOUR AWS ACCESS KEY> \
    -e AWS_SECRET_ACCESS_KEY=<YOUR AWS SECRET ACCESS KEY> \
    475275892927.dkr.ecr.us-east-1.amazonaws.com/delphi/slz-apollo-delphi-migration:develop \
        --dsp spotify \
        --src-bucket <APOLLO S3 BUCKET> \
        --dst-bucket <DELPHI S3 BUCKET> \
        --start-date 2019-04-01 \
        --end-date 2019-04-01 \
        --licensor sony \
        --report-type streams
```
