File: api_cli_differences.md

package info (click to toggle)
freeipa 4.12.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,668 kB
  • sloc: python: 298,952; javascript: 71,606; ansic: 49,369; sh: 6,547; makefile: 2,553; xml: 343; sed: 16
file content (47 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Differences between API and CLI usage

While the functionality between API and CLI is mostly the same, there are some
difference in their usage that should be taken into account.

- [Differences between API and CLI usage](#differences-between-api-and-cli-usage)
  - [Command naming](#command-naming)
  - [Parameter naming](#parameter-naming)
  - [Date format](#date-format)
  - [CLI-specific tools](#cli-specific-tools)

## Command naming

Commands in the CLI are constructed by specifying a topic and an action, with a
hyphen between them: `user-add`, `group-mod`, `host-del`. When accessing through
the API, the topic and the action are divided by an underscore instead:
`user_add`, `group_mod`, `host_del`. All available commands can be found below
`api.Command` after the API is initialized.

## Parameter naming

When managing plugins through the CLI, their parameters have different names
than the API, where names are the same as the LDAP attributes. For example,
`user-add` takes the `first` parameter in the CLI. However, this is named
`givenname` when calling `user_add` through the Python API.

## Date format

When passing dates through the CLI, multiple date string formats are available:

* %Y%m%d%H%M%SZ
* %Y-%m-%dT%H:%M:%SZ
* %Y-%m-%dT%H:%MZ
* %Y-%m-%dZ
* %Y-%m-%d %H:%M:%SZ
* %Y-%m-%d %H:%MZ

When using the API, apart from these formats, the Python built-in `datetime` class
can be used as well.

## CLI-specific tools

FreeIPA provides multiple tools that are mainly useful for CLI usage:

* `console`: starts an interactive Python console with an IPA API object already initialized.
* `help`: shows help about topics and commands, including examples for the CLI.
* `show-mappings`: shows the mapping between CLI parameter names and LDAP attributes.