|
| 1 | +# Remote schema registry |
| 2 | + |
| 3 | +ChargeFlow can push schemas to and remove schemas from a Kafka-compatible schema registry such as |
| 4 | +[Confluent Schema Registry](https://docs.confluent.io/platform/current/schema-registry/index.html) |
| 5 | +or [Redpanda Schema Registry](https://docs.redpanda.com/current/manage/schema-reg/). |
| 6 | + |
| 7 | +All `schema` subcommands share a set of common flags for the registry URL and authentication. |
| 8 | + |
| 9 | +## Common flags |
| 10 | + |
| 11 | +| Flag | Description | Default | |
| 12 | +|------|-------------|---------| |
| 13 | +| `--url` | Remote schema registry URL (required) | — | |
| 14 | +| `--auth-type` | Authentication type: `basic`, `bearer`, `api-key`, or omit for none | — | |
| 15 | +| `--username` | Username for basic authentication | — | |
| 16 | +| `--password` | Password for basic authentication | — | |
| 17 | +| `--bearer-token` | Bearer token | — | |
| 18 | +| `--api-key` | API key value | — | |
| 19 | +| `--api-key-header` | Header name for the API key | `X-API-Key` | |
| 20 | +| `--custom-header` | Custom header name | — | |
| 21 | +| `--custom-value` | Custom header value | — | |
| 22 | +| `--timeout` | Request timeout | `5s` | |
| 23 | + |
| 24 | +## Registering schemas |
| 25 | + |
| 26 | +Use `schema register` to upload JSON schemas to the registry. |
| 27 | + |
| 28 | +### Register a single schema file |
| 29 | + |
| 30 | +`--action` is required when registering a single file. |
| 31 | + |
| 32 | +```bash |
| 33 | +chargeflow schema --url http://localhost:8081 \ |
| 34 | + register --file BootNotificationRequest.json --action BootNotificationRequest |
| 35 | +``` |
| 36 | + |
| 37 | +### Register all schemas from a directory |
| 38 | + |
| 39 | +ChargeFlow reads every `.json` file in the directory and derives the action name from the file name. |
| 40 | + |
| 41 | +```bash |
| 42 | +chargeflow schema --url http://localhost:8081 --version 2.0.1 \ |
| 43 | + register --dir ./schemas |
| 44 | +``` |
| 45 | + |
| 46 | +### Register vendor-specific schemas |
| 47 | + |
| 48 | +Supply `--vendor` and `--model` on the root command to scope the schemas to a specific charging |
| 49 | +station make and model. |
| 50 | + |
| 51 | +```bash |
| 52 | +chargeflow --vendor Acme --model FastCharger \ |
| 53 | + schema --url http://localhost:8081 \ |
| 54 | + register --dir ./vendor-schemas |
| 55 | +``` |
| 56 | + |
| 57 | +## Deleting schemas |
| 58 | + |
| 59 | +Use `schema remove` to delete schemas from the registry. Exactly one of `--action`, `--file`, or |
| 60 | +`--dir` must be specified. |
| 61 | + |
| 62 | +### Delete by action name |
| 63 | + |
| 64 | +```bash |
| 65 | +chargeflow schema --url http://localhost:8081 \ |
| 66 | + remove --action BootNotificationRequest |
| 67 | +``` |
| 68 | + |
| 69 | +### Derive the action from a file name |
| 70 | + |
| 71 | +ChargeFlow strips the `.json` suffix and uses the result as the action name. |
| 72 | + |
| 73 | +```bash |
| 74 | +chargeflow schema --url http://localhost:8081 \ |
| 75 | + remove --file BootNotificationRequest.json |
| 76 | +``` |
| 77 | + |
| 78 | +### Delete all schemas matching a directory |
| 79 | + |
| 80 | +Removes every schema whose action name matches a `.json` file found in the directory. |
| 81 | + |
| 82 | +```bash |
| 83 | +chargeflow schema --url http://localhost:8081 \ |
| 84 | + remove --dir ./schemas |
| 85 | +``` |
| 86 | + |
| 87 | +### Delete vendor-specific schemas |
| 88 | + |
| 89 | +```bash |
| 90 | +chargeflow --vendor Acme --model FastCharger \ |
| 91 | + schema --url http://localhost:8081 \ |
| 92 | + remove --action DataTransfer |
| 93 | +``` |
| 94 | + |
| 95 | +## Authentication examples |
| 96 | + |
| 97 | +### Basic authentication |
| 98 | + |
| 99 | +```bash |
| 100 | +chargeflow schema --url http://registry:8081 \ |
| 101 | + --auth-type basic --username admin --password secret \ |
| 102 | + register --dir ./schemas |
| 103 | +``` |
| 104 | + |
| 105 | +### Bearer token |
| 106 | + |
| 107 | +```bash |
| 108 | +chargeflow schema --url https://registry.example.com \ |
| 109 | + --auth-type bearer --bearer-token eyJ... \ |
| 110 | + register --file MySchema.json --action MyAction |
| 111 | +``` |
| 112 | + |
| 113 | +### API key |
| 114 | + |
| 115 | +The default header is `X-API-Key`. Override it with `--api-key-header` if your registry uses a |
| 116 | +different header name. |
| 117 | + |
| 118 | +```bash |
| 119 | +chargeflow schema --url https://registry.example.com \ |
| 120 | + --auth-type api-key --api-key abc123 \ |
| 121 | + register --dir ./schemas |
| 122 | +``` |
| 123 | + |
| 124 | +### Custom header |
| 125 | + |
| 126 | +```bash |
| 127 | +chargeflow schema --url https://registry.example.com \ |
| 128 | + --custom-header X-Registry-Auth --custom-value my-secret \ |
| 129 | + register --dir ./schemas |
| 130 | +``` |
0 commit comments