Respo create CLI
CLI
Respo CLI command is based on click library. It is not included in module by default, you can install it using pip install respo[cli]
or the best in development, pip install respo[all]
.
We will use respo_model.yml
file generated in provious section.
Respo create
Ok, we already declared resource policies in yml
file. There are few steps before we can use it in Python code, we must:
- read
- validate
- resolve complex rules and nested roles
- save
Note
To get option preview, use respo --help
and respo create --help
You can also change default folder paths of generated files below, using environment variables.
Every part will be covered in another section, now let's use respo create command.
1 2 3 4 5 6 7 |
|
Your folder structure after success should look like:
1 2 3 4 5 6 |
|
Pickled, resolved input file was saved by default to .respo_cache
folder. It should not be included in .gitignore
. It allows better performence when reading policy, no need to validate and resolve input yml file every time on app startup and prevents developer mistake.
But there is also another file, respo_model.py
with following content:
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 |
|
This auto-generated file provides best autocompletion support possible in your Python code, note whole logic is wrapped in typing.TYPE_CHECKING
, it will be understood by your IDE, but generates no additional overhead on the runtime.