\label{doc_tutorials_specification_md_md_doc_tutorials_specification}%
\Hypertarget{doc_tutorials_specification_md_md_doc_tutorials_specification}%
 \hypertarget{doc_tutorials_specification_md_autotoc_md3918}{}\doxysection{Overview}\label{doc_tutorials_specification_md_autotoc_md3918}
\hypertarget{doc_tutorials_specification_md_autotoc_md3919}{}\doxysubsection{Introduction}\label{doc_tutorials_specification_md_autotoc_md3919}
In this tutorial you will learn how to interactively use the {\ttfamily Spec\+Elektra} specification language and {\ttfamily kdb} to write a configuration specification for an example application.\hypertarget{doc_tutorials_specification_md_autotoc_md3920}{}\doxysubsection{What you should already know}\label{doc_tutorials_specification_md_autotoc_md3920}

\begin{DoxyItemize}
\item how to install Elektra
\item basic Elektra commands and concepts (kdb get, kdb set, kdb ls)
\item how to open and use a terminal
\end{DoxyItemize}\hypertarget{doc_tutorials_specification_md_autotoc_md3921}{}\doxysubsection{What you’ll Learn}\label{doc_tutorials_specification_md_autotoc_md3921}

\begin{DoxyItemize}
\item how to create and mount a specification using {\ttfamily kdb}
\item how to add keys with different types, defaults and examples to your specification and how to validate them
\item the benefits of using {\ttfamily kdb} to generate a specification, instead of writing one by hand
\end{DoxyItemize}\hypertarget{doc_tutorials_specification_md_autotoc_md3922}{}\doxysubsection{What you\textquotesingle{}ll do}\label{doc_tutorials_specification_md_autotoc_md3922}

\begin{DoxyItemize}
\item use {\ttfamily kdb} to create and mount a specification for an example CRUD (Create, Read, Update, Delete) application
\item define defaults, examples and checks for keys in the validation
\end{DoxyItemize}\hypertarget{doc_tutorials_specification_md_autotoc_md3923}{}\doxysection{Example App Overview}\label{doc_tutorials_specification_md_autotoc_md3923}
For this tutorial you will write a specification for a simple CRUD backend application. You need to configure a {\ttfamily port} and a {\ttfamily secure} property, that toggles SSL usage, for the REST server. An {\ttfamily ip} and a SQL {\ttfamily dialect} for the database server the app will connect to and finally a {\ttfamily date} where all the data will be saved to a backup.

So the application will need the following configuration options\+:


\begin{DoxyItemize}
\item a server port
\item server secure
\item a database ip
\item a database dialect
\item a backup date
\end{DoxyItemize}\hypertarget{doc_tutorials_specification_md_autotoc_md3924}{}\doxysection{Getting Started}\label{doc_tutorials_specification_md_autotoc_md3924}
Make sure you have {\ttfamily Elektra} installed on your local machine\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb -\/-\/version}
\DoxyCodeLine{}
\DoxyCodeLine{KDB\_VERSION: 0.9.6}
\DoxyCodeLine{SO\_VERSION: 5}

\end{DoxyCode}


Otherwise refer to the \href{https://www.libelektra.org/getstarted/guide}{\texttt{ getting started guide}} to install it.\hypertarget{doc_tutorials_specification_md_autotoc_md3925}{}\doxysection{Mounting the Specification}\label{doc_tutorials_specification_md_autotoc_md3925}
\hypertarget{doc_tutorials_specification_md_autotoc_md3926}{}\doxysubsection{Step 1\+: Mount a Specification File}\label{doc_tutorials_specification_md_autotoc_md3926}
First you need to mount a specification file, in this case {\ttfamily spec.\+ni} to the {\ttfamily spec\+:/} namespace. You can define the path inside the {\ttfamily spec\+:/} namespace as {\ttfamily /sw/org/app/\#0/current}, refer to \href{https://www.libelektra.org/tutorials/integration-of-your-c-application}{\texttt{ the documentation}} to find out more about constructing the name.

You will also be using the profile {\ttfamily current}, you can find out more about profiles in \href{https://www.libelektra.org/plugins/profile}{\texttt{ the documentation}} as well.

You also need to specify the plugin you will use for writing to the file in the correct format. In this case you can choose the {\ttfamily ni} plugin to write to the specification file.


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount `pwd`/spec.ni spec:/sw/org/app/\(\backslash\)\#0/current ni}

\end{DoxyCode}


Using the command below you can list the directory of the concrete file that is used by Elektra.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb file spec:/sw/org/app/\(\backslash\)\#0/current}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3927}{}\doxysubsection{Step 2\+: Define a mountpoint}\label{doc_tutorials_specification_md_autotoc_md3927}
Next you can define, that this specification defines a specific mountpoint for a concrete application configuration. So you can say the concrete configuraion should be written to {\ttfamily app.\+ni}.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current mountpoint app.ni}

\end{DoxyCode}


Your {\ttfamily spec.\+ni} file should now look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{ =}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3928}{}\doxysubsection{Step 3\+: Do a specification mount}\label{doc_tutorials_specification_md_autotoc_md3928}

\begin{DoxyCode}{0}
\DoxyCodeLine{kdb spec-\/mount /sw/org/app/\(\backslash\)\#0/current ni}

\end{DoxyCode}


This specification mount makes sure that the paths where the concrete configuration should be, in this case {\ttfamily app.\+ni}, are ready to fulfill or specification, in this case {\ttfamily spec.\+ni}.\hypertarget{doc_tutorials_specification_md_autotoc_md3929}{}\doxysection{Adding your first key to the specification}\label{doc_tutorials_specification_md_autotoc_md3929}
\hypertarget{doc_tutorials_specification_md_autotoc_md3930}{}\doxysubsection{Step 1\+: Adding the server port}\label{doc_tutorials_specification_md_autotoc_md3930}
The first key you will add to our specification will be the port of the server. You add it using the following command below.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/port type short}

\end{DoxyCode}


What you also specified in the command above is the type of the configuration key. Elektra uses the \href{https://www.libelektra.org/plugins/type}{\texttt{ CORBA type system}} and will check that keys conform to the type specified.

So after adding the initial key your specification should look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/type = short}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3931}{}\doxysubsection{Step 2\+: Adding more metadata}\label{doc_tutorials_specification_md_autotoc_md3931}
So with your first key added, you of course want to specify more information for the port. There surely is more information to a port than just the type. What about a {\ttfamily default}, or what about an {\ttfamily example} for a usable port? Maybe a {\ttfamily description} what the port really is for? Let\textquotesingle{}s add that next!


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/port default 8080}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/port example 8080}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/port description "{}port of the REST server that runs the application"{}}

\end{DoxyCode}


Beautiful! Your specification is starting to look like something useful. But wait! Shouldn\textquotesingle{}t a port just use values between {\ttfamily 1} and {\ttfamily 65535}?

Of course Elektra also has a plugin for that. You can just use the \href{https://www.libelektra.org/plugins/network}{\texttt{ network}} checker plugin.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/port check/port ''}

\end{DoxyCode}


Nice! You just have to do one more thing when using a new plugin. Elektra needs to remount the spec to use the new plugin. Use the command from before\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb spec-\/mount /sw/org/app/\(\backslash\)\#0/current ni}

\end{DoxyCode}


Your final specification after adding the port should now look something like this


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/check/port =}
\DoxyCodeLine{ meta:/type = short}
\DoxyCodeLine{ meta:/example = 8080}
\DoxyCodeLine{ meta:/description = port of the REST server that runs the application}
\DoxyCodeLine{ meta:/default = 8080}

\end{DoxyCode}


You can now try to read the value of the newly created configuration. Since you did not set the value to anything yet, you will get the default value back.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb get /sw/org/app/\(\backslash\)\#0/current/server/port}
\DoxyCodeLine{}
\DoxyCodeLine{\#>8080}

\end{DoxyCode}


Try to set the port to {\ttfamily 123456} now.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb set /sw/org/app/\(\backslash\)\#0/current/server/port 123456}
\DoxyCodeLine{\# STDERR: Port 123456 on key /server/port was not within 0 -\/ 65535}

\end{DoxyCode}


Did it work? I hope not. The validation plugin you specified will now correctly validate the port you enter and give you an error.\hypertarget{doc_tutorials_specification_md_autotoc_md3932}{}\doxysubsection{Step 3\+: Adding boolean keys}\label{doc_tutorials_specification_md_autotoc_md3932}
Next up you will configure the {\ttfamily secure} property of our server. This boolean key will toggle if your server encrypts the communication via SSL.

So we will add the key and some metadata for it\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/secure type boolean}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/secure default 1}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/secure example 0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/server/secure description "{}true if the REST server uses SSL for communication"{}}

\end{DoxyCode}


By default the {\ttfamily type} plugin will normalize boolean values when setting them, before storing them. This only works for the concrete config, so when setting the values for the spec you have to use the unnormalized values. In the case it uses {\ttfamily 1} for boolean {\ttfamily true} and {\ttfamily 0} for boolean {\ttfamily false}.

You can read more about this in the documentation for the \href{https://www.libelektra.org/plugins/type\#normalization}{\texttt{ type plugin}}.\hypertarget{doc_tutorials_specification_md_autotoc_md3933}{}\doxysection{Adding the database keys to the specification}\label{doc_tutorials_specification_md_autotoc_md3933}
\hypertarget{doc_tutorials_specification_md_autotoc_md3934}{}\doxysubsection{Step 1\+: Adding the database ip}\label{doc_tutorials_specification_md_autotoc_md3934}
Next up you will add a key for the database {\ttfamily ip} address. Like with the key before, you will add a {\ttfamily type}, {\ttfamily default}, {\ttfamily example} and a {\ttfamily description} so that the configuration will be easily usable.

Don\textquotesingle{}t forget the most important rule of configurations\+: {\bfseries{Always add sensible defaults!}}

Now let\textquotesingle{}s try something different. What if you change the file manually? Will Elektra pick up on the changes? And save you from writing {\bfseries{a lot}} of {\ttfamily kdb} commands?

{\itshape of course}

So just open your file using good old {\ttfamily vim} and add the following lines to specify configuration for the {\ttfamily ip} address.


\begin{DoxyCode}{0}
\DoxyCodeLine{vim \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{database/ip =}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{server/secure =}
\DoxyCodeLine{}
\DoxyCodeLine{[database/ip]}
\DoxyCodeLine{ meta:/check/ipaddr =}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 127.0.0.1}
\DoxyCodeLine{ meta:/description = ip address of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/default = 127.0.0.1}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/check/port =}
\DoxyCodeLine{ meta:/type = short}
\DoxyCodeLine{ meta:/example = 8080}
\DoxyCodeLine{ meta:/description = port of the REST server that runs the application}
\DoxyCodeLine{ meta:/default = 8080}
\DoxyCodeLine{}
\DoxyCodeLine{[server/secure]}
\DoxyCodeLine{ meta:/type = boolean}
\DoxyCodeLine{ meta:/example = 0}
\DoxyCodeLine{ meta:/description = true if the REST server uses SSL for communication}
\DoxyCodeLine{ meta:/default = 1}

\end{DoxyCode}


Alternatively you can of course use {\ttfamily kdb} again to set the configuration values that way. Here are the commands to do that.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/ip type string}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/ip default 127.0.0.1}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/ip example 127.0.0.1}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/ip description "{}ip address of the database server, that the application will connect to"{}}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/ip check/ipaddr ''}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3935}{}\doxysubsection{Step 2\+: Adding the database dialect}\label{doc_tutorials_specification_md_autotoc_md3935}
Next up you will add a key for the SQL {\ttfamily dialect} the database will use. Since there are only a few databases your application will support, you can define the possible dialects via an \href{https://www.libelektra.org/plugins/type\#enums}{\texttt{ enum}} type. This allows us to prohibit all other possible dialects that are not SQL.

First you define the size of the {\ttfamily enum} type, and then you can add the different {\ttfamily enum} values.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect type enum}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum "{}\#4"{}}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum/\(\backslash\)\#0 postgresql}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum/\(\backslash\)\#1 mysql}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum/\(\backslash\)\#2 mssql}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum/\(\backslash\)\#3 mariadb}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect check/enum/\(\backslash\)\#4 sqlite}

\end{DoxyCode}


Afterwards you define all the other parameters, just as before.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect default sqlite}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect example mysql}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/database/dialect description "{}SQL dialect of the database server, that the application will connect to"{}}

\end{DoxyCode}


After this meta-\/setting bonanza your specification file should look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{database/ip =}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{server/secure =}
\DoxyCodeLine{database/dialect =}
\DoxyCodeLine{}
\DoxyCodeLine{[database/ip]}
\DoxyCodeLine{ meta:/check/ipaddr =}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 127.0.0.1}
\DoxyCodeLine{ meta:/description = ip address of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/default = 127.0.0.1}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/check/port =}
\DoxyCodeLine{ meta:/type = short}
\DoxyCodeLine{ meta:/example = 8080}
\DoxyCodeLine{ meta:/description = port of the REST server that runs the application}
\DoxyCodeLine{ meta:/default = 8080}
\DoxyCodeLine{}
\DoxyCodeLine{[server/secure]}
\DoxyCodeLine{ meta:/type = boolean}
\DoxyCodeLine{ meta:/example = 0}
\DoxyCodeLine{ meta:/description = true if the REST server uses SSL for communication}
\DoxyCodeLine{ meta:/default = 1}
\DoxyCodeLine{}
\DoxyCodeLine{[database/dialect]}
\DoxyCodeLine{ meta:/check/enum/\#2 = mssql}
\DoxyCodeLine{ meta:/check/enum/\(\backslash\)\#0 = postgresql}
\DoxyCodeLine{ meta:/type = enum}
\DoxyCodeLine{ meta:/check/enum/\#1 = mysql}
\DoxyCodeLine{ meta:/example = mysql}
\DoxyCodeLine{ meta:/description = SQL dialect of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/check/enum/\#4 = sqlite}
\DoxyCodeLine{ meta:/check/enum/\#3 = mariadb}
\DoxyCodeLine{ meta:/default = sqlite}
\DoxyCodeLine{ meta:/check/enum = \#4}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3936}{}\doxysection{Adding the backup date}\label{doc_tutorials_specification_md_autotoc_md3936}
The last key you will add to our application is a {\ttfamily date} key for the annual backup and restart (this should probably not be annually in a real application). Here you use the \href{https://www.libelektra.org/plugins/date}{\texttt{ check/date}} plugin with the {\ttfamily ISO8601} format. You also specify a {\ttfamily check/date/format}. You can find all possible date formats on the \href{https://www.libelektra.org/plugins/date}{\texttt{ plugin page}}. For this you can use the following commands\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date type string}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date check/date ISO8601}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date check/date/format "{}calendardate complete extended"{}}

\end{DoxyCode}


Then just add examples, defaults and description as always.


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date default 2021-\/11-\/01}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date example 2021-\/01-\/12}
\DoxyCodeLine{kdb meta-\/set spec:/sw/org/app/\(\backslash\)\#0/current/backup/date description "{}date of the annual server and database backup"{}}

\end{DoxyCode}


Your specification looks to be complete now! Make sure it looks something like the one below and you are good to go using it and configuring the heck out of it!


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{backup/date =}
\DoxyCodeLine{database/ip =}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{server/secure =}
\DoxyCodeLine{database/dialect =}
\DoxyCodeLine{}
\DoxyCodeLine{[backup/date]}
\DoxyCodeLine{ meta:/check/date/format = calendardate complete extended}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 2021-\/01-\/12}
\DoxyCodeLine{ meta:/description = date of the annual server and database backup}
\DoxyCodeLine{ meta:/default = 2021-\/11-\/01}
\DoxyCodeLine{ meta:/check/date = ISO8601}
\DoxyCodeLine{}
\DoxyCodeLine{[database/ip]}
\DoxyCodeLine{ meta:/check/ipaddr =}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 127.0.0.1}
\DoxyCodeLine{ meta:/description = ip address of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/default = 127.0.0.1}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/check/port =}
\DoxyCodeLine{ meta:/type = short}
\DoxyCodeLine{ meta:/example = 8080}
\DoxyCodeLine{ meta:/description = port of the REST server that runs the application}
\DoxyCodeLine{ meta:/default = 8080}
\DoxyCodeLine{}
\DoxyCodeLine{[server/secure]}
\DoxyCodeLine{ meta:/type = boolean}
\DoxyCodeLine{ meta:/example = 0}
\DoxyCodeLine{ meta:/description = true if the REST server uses SSL for communication}
\DoxyCodeLine{ meta:/default = 1}
\DoxyCodeLine{}
\DoxyCodeLine{[database/dialect]}
\DoxyCodeLine{ meta:/check/enum/\#2 = mssql}
\DoxyCodeLine{ meta:/check/enum/\(\backslash\)\#0 = postgresql}
\DoxyCodeLine{ meta:/type = enum}
\DoxyCodeLine{ meta:/check/enum/\#1 = mysql}
\DoxyCodeLine{ meta:/example = mysql}
\DoxyCodeLine{ meta:/description = SQL dialect of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/check/enum/\#4 = sqlite}
\DoxyCodeLine{ meta:/check/enum/\#3 = mariadb}
\DoxyCodeLine{ meta:/default = sqlite}
\DoxyCodeLine{ meta:/check/enum = \#4}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3937}{}\doxysection{Final specification code}\label{doc_tutorials_specification_md_autotoc_md3937}
After adding all the keys that are necessary for our application to the server, your specification should look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{cat \$(kdb file spec:/sw/org/app/\(\backslash\)\#0/current)}
\DoxyCodeLine{}
\DoxyCodeLine{;Ni1}
\DoxyCodeLine{; Generated by the ni plugin using Elektra (see libelektra.org).}
\DoxyCodeLine{}
\DoxyCodeLine{backup/date =}
\DoxyCodeLine{database/ip =}
\DoxyCodeLine{ =}
\DoxyCodeLine{server/port =}
\DoxyCodeLine{server/secure =}
\DoxyCodeLine{database/dialect =}
\DoxyCodeLine{}
\DoxyCodeLine{[backup/date]}
\DoxyCodeLine{ meta:/check/date/format = calendardate complete extended}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 2021-\/01-\/12}
\DoxyCodeLine{ meta:/description = date of the annual server and database backup}
\DoxyCodeLine{ meta:/default = 2021-\/11-\/01}
\DoxyCodeLine{ meta:/check/date = ISO8601}
\DoxyCodeLine{}
\DoxyCodeLine{[database/ip]}
\DoxyCodeLine{ meta:/check/ipaddr =}
\DoxyCodeLine{ meta:/type = string}
\DoxyCodeLine{ meta:/example = 127.0.0.1}
\DoxyCodeLine{ meta:/description = ip address of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/default = 127.0.0.1}
\DoxyCodeLine{}
\DoxyCodeLine{[]}
\DoxyCodeLine{ meta:/mountpoint = app.ni}
\DoxyCodeLine{}
\DoxyCodeLine{[server/port]}
\DoxyCodeLine{ meta:/check/port =}
\DoxyCodeLine{ meta:/type = short}
\DoxyCodeLine{ meta:/example = 0}
\DoxyCodeLine{ meta:/description = port of the REST server that runs the application}
\DoxyCodeLine{ meta:/default = 1}
\DoxyCodeLine{}
\DoxyCodeLine{[server/secure]}
\DoxyCodeLine{ meta:/type = boolean}
\DoxyCodeLine{ meta:/example = false}
\DoxyCodeLine{ meta:/description = true if the REST server uses SSL for communication}
\DoxyCodeLine{ meta:/default = false}
\DoxyCodeLine{}
\DoxyCodeLine{[database/dialect]}
\DoxyCodeLine{ meta:/check/enum/\#2 = mssql}
\DoxyCodeLine{ meta:/check/enum/\(\backslash\)\#0 = postgresql}
\DoxyCodeLine{ meta:/type = enum}
\DoxyCodeLine{ meta:/check/enum/\#1 = mysql}
\DoxyCodeLine{ meta:/example = mysql}
\DoxyCodeLine{ meta:/description = SQL dialect of the database server, that the application will connect to}
\DoxyCodeLine{ meta:/check/enum/\#4 = sqlite}
\DoxyCodeLine{ meta:/check/enum/\#3 = mariadb}
\DoxyCodeLine{ meta:/default = sqlite}
\DoxyCodeLine{ meta:/check/enum = \#4}

\end{DoxyCode}
\hypertarget{doc_tutorials_specification_md_autotoc_md3938}{}\doxysection{Summary}\label{doc_tutorials_specification_md_autotoc_md3938}

\begin{DoxyItemize}
\item You set up and mounted a specification using {\ttfamily kdb mount} and {\ttfamily kdb spec-\/mount}
\item You added keys the specification using {\ttfamily kdb meta-\/set}
\item You added different types of keys with {\ttfamily type string}, {\ttfamily type boolean} or {\ttfamily type short}
\item You added keys with enum types, to get specific configuration values, with \`{}{\ttfamily }
\item {\ttfamily You added default parameters, examples and descriptions with}example{\ttfamily ,}default{\ttfamily ,}description{\ttfamily }
\item {\ttfamily You also added validation checks using different plugins, like}check/port{\ttfamily or}check/ipaddr\`{}
\end{DoxyItemize}\hypertarget{doc_tutorials_specification_md_autotoc_md3939}{}\doxysection{Learn more}\label{doc_tutorials_specification_md_autotoc_md3939}

\begin{DoxyItemize}
\item \href{https://www.libelektra.org/tutorials/readme}{\texttt{ Tutorial Overview}} 
\end{DoxyItemize}