Odorik command line interface¶
Synopsis¶
odorik [parameter] <command> [options]
Commands actually indicate which operation should be performed.
Description¶
This module also installs odorik program, which allows you to easily access some of the functionality from command line.
Global options¶
The program accepts following global options, which must be entered before subcommand.
-
--format
{csv,json,text,html}
¶ Specify output format.
Subcommands¶
Currently following subcommands are available:
-
version
¶
Prints current version.
-
api
PATH [--post] [--param KEY=VALUE]...
¶ Performs authenticated API call. By default
GET
method is used, with--post
it isPOST
.Additional parameters can be specified by
--param
switch which can be used multiple times.
-
balance
¶
Prints current balance.
-
mobile-data
[--list] [--phone NUMBER] [--all] [DATE PERIOD]
¶ Prints mobile data usage.
It can list all individual records when
--list
is specified.The result can be also limited to given phone number by using
--phone
. The phone number has to be specified as00420789123456
.If
--all
is specified, summary for all mobile lines on current account is printed.See Specifying date period for information how to specify date period.
-
calls
[--list] [--line LINE] [--direction {in,out,redirected}] [--status {answered,missed}] [DATE PERIOD]
¶ Prints calls usage.
It can list all individual records when
--list
is specified.The result can be also limited to given line by using
--line
.You can additionally filter calls by
--status
or--direction
.See Specifying date period for information how to specify date period.
-
sms
[--list] [--line LINE] [DATE PERIOD]
¶ Prints SMS usage.
It can list all individual records when
--list
is specified.The result can be also limited to given line by using
--line
.See Specifying date period for information how to specify date period.
-
send-sms
[--sender SENDER] recipient message
¶ Sends a SMS message.
You can specify sender number by
--sender
, it has to be one of allowed values. By default5517
is used.
-
callback
[--line LINE] caller recipient
¶ Initiates a callback.
-
lines
[--generate-config]
¶ Prints infromation about lines.
With
--generate-config
it generates config file entries for line and phone number aliases, see Files.
-
summary
[DATE PERIOD]
¶ Prints summary information for all lines in current account.
See Specifying date period for information how to specify date period.
Specifying date period¶
You can specify date period for which many commands will be issued:
-
--this-month
¶
Prints information for current month. This is the default interval.
-
--last-month
¶
Prints information for last month.
-
--start-date
DATE
¶ Starting datetime.
-
--end-date
DATE
¶ Ending datetime. If not specified, current date is used.
All parameters accepting date can take almost any format of date or timestamp. Check dateutil documentation for more detailed information (especially on year/month/day precendence).
Files¶
~/.config/odorik
- User configuration file
/etc/xdg/odorik
- Global configration file
The program follows XDG specification, so you can adjust placement of config files
by environment variables XDG_CONFIG_HOME
or XDG_CONFIG_DIRS
.
Following settings can be configured in the [odorik]
section (you can
customize this by --config-section
):
-
user
API user, can be either ID registered user or line ID.
-
password
API password. Use API password for per user access and line password (used for SIP as well) for line access.
-
url
API server URL, defaults to
https://www.odorik.cz/api/v1/
.
See Autentizace Odorik API for more details on authentication.
The configuration file is INI file, for example:
[odorik]
user = pepa
password = zdepa
Additionally config file can include phone number and line aliases:
[lines]
pepa = 12345
[numbers]
pepa = 00420789789789
franta = 00420789123456
Examples¶
Print current program version:
$ odorik version
version: 0.1
Print current user balance:
$ odorik balance
balance: 123.45
Prints current mobile data usage:
$ odorik mobile-data --phone 00420789123456
bytes_total: 111593707
bytes_down: 87039672
bytes_up: 24554035
price: 0
Sending message:
$ odorik send-sms 00420789123456 "Ahoj, jak se mas?"
Initiating callback:
$ odorik callback 00420789123456 800123456
Getting account summary:
$ odorik summary
Pepa
id: 716000
public_number: 00420789789789
call_count: 58
sms_count: 42
bytes_total: 145921813
data_price: 0.01
call_price: 24.28
sms_price: 12.31
price: 36.59
Franta
id: 717000
public_number: 00420789123456
call_count: 11
sms_count: 0
bytes_total: 0
data_price: 0
call_price: 2.20
sms_price: 0
price: 2.20
Generic API usage:
$ odorik api sms/allowed_sender
Odorik.cz,5517,00420789123456
Generic API POST:
$ odorik api --post --param caller=00420789123456 --param recipient=800123456 callback
Machine readable output formats:
$ odorik --format json mobile-data
{
"bytes_total": 111593707,
"bytes_down": 87039672,
"bytes_up": 24554035,
"price": 0.008
}
$ odorik --format csv mobile-data
bytes_total,111593707
bytes_down,87039672
bytes_up,24554035
price,0.008