# epx units

> Read and change units of measurement; read unit types and convert between units.

## epx units

Reads units of measurement. TYPE groups units that convert into each other, BASE marks
the base unit of a type, and FACTOR converts a unit into its type's base unit, as sent by
Emporix (g: 0.001 when kg is the base). [`epx units types`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-types) lists the types;
[`epx units convert`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-convert) and `conversion-factor` convert between units of a type.
[`epx units create`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-create), `update`, `delete` and `bulk-delete` change the units.

Its reads need no OAuth scope.
Its writes require the unithandling.unit_manage scope.

**Command:** `epx units [flags]`, `epx units [command]`

**Flags:** only the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

**Subcommands**

- [`epx units bulk-delete`](#epx-units-bulk-delete)\
  Delete units by their codes.
- [`epx units conversion-factor`](#epx-units-conversion-factor)\
  Calculate the factor that converts one unit into another.
- [`epx units convert`](#epx-units-convert)\
  Convert an amount from one unit into another.
- [`epx units create`](#epx-units-create)\
  Create a unit.
- [`epx units delete`](#epx-units-delete)\
  Delete a unit.
- [`epx units get`](#epx-units-get)\
  Show one unit.
- [`epx units list`](#epx-units-list)\
  List units.
- [`epx units types`](#epx-units-types)\
  List unit types.
- [`epx units update`](#epx-units-update)\
  Update a unit.

## epx units bulk-delete

Delete units by their codes.

Deletes the units whose codes the JSON array of `--file` names, such as `["g", "kg"]`.
Other services see the change after up to 5 minutes.

Deletes the units whose codes `--file` names with one request, which cannot be undone.
On a terminal, epx sends DELETE only once you type the tenant at its prompt.
`--yes` sends without asking (required without a terminal, or with `--file` -);
`--dry-run` prints the request instead of sending it.

Requires the unithandling.unit_manage scope.

**Command:** `epx units bulk-delete [flags]`

**Flags**

- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `--file <PATH>`\
  JSON request body in PATH, sent byte for byte (- reads standard input; sending it then needs `--yes`; required).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal, or with `--file` -).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units conversion-factor

Calculate the factor that converts one unit into another.

Calculates the FACTOR that converts one unit into another of the same type
([`epx units list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-list) shows their codes and types): an amount in FROM units times FACTOR is
the amount in TO units.
An unknown unit is not found (exit 4); Emporix answers units of different types with
400 Bad Request (exit 1).

Changes nothing: Emporix serves this read as PUT with a JSON body, which the
flags make or `--body` gives whole.

No OAuth scope is needed.

**Command:** `epx units conversion-factor [flags]`

**Flags**

- `--body <FILE>`\
  Send the JSON request body in FILE as given (- reads standard input) instead of the one the other flags make.
- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among FROM, TO, FACTOR.
- `--from <CODE>`\
  The CODE of the unit to convert from (required without `--body`).
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.
- `--to <CODE>`\
  The CODE of the unit to convert to (required without `--body`).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units convert

Convert an amount from one unit into another.

Converts an `--amount` of one unit into another of the same type ([`epx units list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-list) shows
their codes and types): FROM is the amount given, TO what it converts to.
An unknown unit is not found (exit 4); Emporix answers units of different types with
400 Bad Request (exit 1).

Changes nothing: Emporix serves this read as PUT with a JSON body, which the
flags make or `--body` gives whole.

No OAuth scope is needed.

**Command:** `epx units convert [flags]`

**Flags**

- `--amount <AMOUNT>`\
  The AMOUNT to convert, in `--from` units (required without `--body`).
- `--body <FILE>`\
  Send the JSON request body in FILE as given (- reads standard input) instead of the one the other flags make.
- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among FROM, TO.
- `--from <CODE>`\
  The CODE of the unit to convert from (required without `--body`).
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.
- `--to <CODE>`\
  The CODE of the unit to convert to (required without `--body`).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units create

Create a unit.

Creates the unit that the JSON body of `--file` describes: its code, name, type, baseUnit
(whether it is the base unit of its type) and factor (what converts it into the base unit,
greater than zero), and its symbol if any. Emporix answers with the unit's code; a unit
with the code exists already: a conflict (exit 5).
Other services see the change after up to 5 minutes.

Localized text in the body, such as a name, is a map of translations, e.g.
`{"en": "gram", "de": "Gramm"}`, as `-o json` of a read prints it, or with `--content-language`
LANGUAGE a string in that language, e.g. `"gram"` with `--content-language` en.

Changes data: on a terminal, epx asks before it sends POST. `--yes` sends without
asking (required without a terminal, or with `--file` -); `--dry-run` prints the request
instead of sending it.

Requires the unithandling.unit_manage scope.

**Command:** `epx units create [flags]`

**Flags**

- `--content-language <LANGUAGE>`\
  The LANGUAGE of localized text in the body, or \* for maps of translations. Default: `*`.
- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `--file <PATH>`\
  JSON request body in PATH, sent byte for byte (- reads standard input; sending it then needs `--yes`; required).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal, or with `--file` -).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units delete

Delete a unit.

Deletes the unit CODE, as [`epx units list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-list) shows it.
Other services see the change after up to 5 minutes.

Deletes data, which cannot be undone.
On a terminal, epx sends DELETE only once you type CODE at its prompt.
`--yes` sends without asking (required without a terminal);
`--dry-run` prints the request instead of sending it.

Requires the unithandling.unit_manage scope.

**Command:** `epx units delete CODE [flags]`

**Flags**

- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units get

Show one unit.

Reads units of measurement. TYPE groups units that convert into each other, BASE marks
the base unit of a type, and FACTOR converts a unit into its type's base unit, as sent by
Emporix (g: 0.001 when kg is the base). [`epx units types`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-types) lists the types;
[`epx units convert`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-convert) and `conversion-factor` convert between units of a type.
[`epx units create`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-create), `update`, `delete` and `bulk-delete` change the units.

No OAuth scope is needed.

**Command:** `epx units get CODE [flags]`

**Flags**

- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among CODE, NAME, TYPE, SYMBOL, BASE, FACTOR.
- `--language <language>`\
  Language of localized table text; a missing translation shows another, labeled (`-o json` prints all). Default: `en`.
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units list

List units.

Reads units of measurement. TYPE groups units that convert into each other, BASE marks
the base unit of a type, and FACTOR converts a unit into its type's base unit, as sent by
Emporix (g: 0.001 when kg is the base). [`epx units types`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-types) lists the types;
[`epx units convert`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-convert) and `conversion-factor` convert between units of a type.
[`epx units create`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-create), `update`, `delete` and `bulk-delete` change the units.

No OAuth scope is needed.

**Command:** `epx units list [flags]`

**Flags**

- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among CODE, NAME, TYPE, SYMBOL, BASE, FACTOR.
- `--language <language>`\
  Language of localized table text; a missing translation shows another, labeled (`-o json` prints all). Default: `en`.
- `--limit <n>`\
  Print at most n items; paged reads stop early where they safely can (0: every item).
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.
- `--sort <order>`\
  Emporix sort order, passed as given, e.g. code or name.en:desc,code; fields mostly as in `-o json` (Emporix may ignore an unknown one).
- `--stream`\
  Print items as JSON Lines as soon as they are checked, page by page on paged lists, reading up to 10000 pages where a list without it stops after 1000: a check failing on a later page exits 1 after the pages before it (excludes `-o`, `--columns` and `--no-headers`).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units types

List unit types.

Reads the unit types: the values that the TYPE of a unit takes.

No OAuth scope is needed.

**Command:** `epx units types [flags]`

**Flags**

- `--columns <names>`\
  Print only these columns of table and csv, in this order: comma-separated names (any case) among TYPE.
- `--limit <n>`\
  Print at most n items; paged reads stop early where they safely can (0: every item).
- `--no-headers`\
  Print table and csv without the header row.
- `-o, --output <format>`\
  Output format: table, json, yaml or csv (csv: the table's rows; json and yaml: the whole response). Default: `table`.
- `--stream`\
  Print items as JSON Lines as soon as they are checked, page by page on paged lists, reading up to 10000 pages where a list without it stops after 1000: a check failing on a later page exits 1 after the pages before it (excludes `-o`, `--columns` and `--no-headers`).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).

## epx units update

Update a unit.

Replaces the unit CODE (the CODE that [`epx units list`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-list) shows) with the unit that the JSON
body of `--file` describes, as create does, with the same code; Emporix creates no missing
unit. With metadata.version in the body, as [`epx units get CODE -o json`](https://commerce-cloud-integrations.github.io/emporix-cli/commands/units#epx-units-get) prints it, Emporix
replaces only that version of the unit, and answers an older one as it answers an unknown
unit, with 404 Not Found: epx then exits with 5, a conflict (read the unit again before
you retry), and without a version with 4, not found.
Other services see the change after up to 5 minutes.

Localized text in the body, such as a name, is a map of translations, e.g.
`{"en": "gram", "de": "Gramm"}`, as `-o json` of a read prints it, or with `--content-language`
LANGUAGE a string in that language, e.g. `"gram"` with `--content-language` en.
Such a string replaces the unit's other translations of that text; send the map to keep them.

Changes data: on a terminal, epx asks before it sends PUT. `--yes` sends without
asking (required without a terminal, or with `--file` -); `--dry-run` prints the request
instead of sending it.

Requires the unithandling.unit_manage scope.

**Command:** `epx units update CODE [flags]`

**Flags**

- `--content-language <LANGUAGE>`\
  The LANGUAGE of localized text in the body, or \* for maps of translations. Default: `*`.
- `--dry-run`\
  Print the request instead of sending it (excludes `-o`).
- `--file <PATH>`\
  JSON request body in PATH, sent byte for byte (- reads standard input; sending it then needs `--yes`; required).
- `-o, --output <format>`\
  Format of the response: json or yaml. Default: `json`.
- `--yes`\
  Send without asking (required without a terminal, or with `--file` -).

Also takes the [global flags](https://commerce-cloud-integrations.github.io/emporix-cli/commands#global-flags).
