1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2017 Huawei Technologies Co., Ltd.
5 .. _open_cli_schema_version_1_0:
7 Open Command Line Interface (CLI) Schema Version (OCS) 1.0
8 ==========================================================
10 Open CLI Platform (OCLIP) provides model based framework to implement
11 Linux Commands for any given software products, by using YAML template
12 based on the schematics defined in this document. In version 1.0,
13 following aspects of commands are modeled as YAML schematics:
15 * Basic Command information
17 * Command line arguments
21 * Software product information
27 open_cli_schema_version
28 -----------------------
29 OCLIP considers any YAML file with first line having the following entry
32 open_cli_schema_version: 1.0
34 Here, 1.0 version is first version of this schema. In future, this version
35 number will get incremented based on addition of new schematics or update of
40 *name* entry allows to set the command name and it is recommended to use the
45 entity - Resource or a feature, for which command is provided
47 action - Functionality performed on the entity
49 For example, to implement a command to *start* a given *service*.
52 **name** : **service-start**
54 *CAUTION*: name should not have any space character in it.
58 *description* entry allows to write detailed usage of the command. It could be
59 a line or a paragraph as given example here.
63 description: Start the given service
68 Start the given service. To see the available services in the system
69 use the command *service-list*
75 *product* entry allows to tag the command template with the software product
76 name and version, for which command is implemented and is recommended to use
81 product - Short name of the product
83 action - Version of the product
85 For example, to implement a command for Open Network Automation Platform
86 (onap) version amsterdam, set the version as:
88 **product** : **onap-amsterdam**
90 *CAUTION*: product should not have any space character in it.
95 Every command has set of arguments to provide the input values and *parameters*
96 section allows to add the required arguments details such as name, description,
97 etc as list of entries.
101 *name* entry uniquely identifies the given argument. It can be of any
102 alpha-numerical characters and dash(-). For example to provide the http port of
103 an service, the parameter could be:
106 \- **name: service-port**
110 *description* entry allows to provide the details of the parameter. Its
111 supported in similar approach with command *description* defined in above
112 section. For example service-port could be described as:
115 \- name: service-port
117 **description: Service HTTP port.**
121 *is_optional* entry allows to set the parameter is mandatory or not. By default,
122 this entry is false. For example service-port could be made as as optional:
125 \- name: service-port
127 description: Service HTTP port.
129 **is_optional: true**
133 *is_secured* entry allows to set the parameter is secured or not. By default,
134 this entry is false. This is very useful for password kind of parameters.
136 For example service-port could be made as in-secured:
139 \- name: service-port
141 description: Service HTTP port.
145 **is_secured: false**
149 *default_value* entry helps to provide the default value for the given parameter
150 when that parameter is not provided during command execution.
152 Based on the *type* of parameter, default values are assigned as:
154 +---------------+------------------------------------------------------------+
155 | Type | Default value |
156 +===============+============================================================+
158 +---------------+------------------------------------------------------------+
159 | uuid | Auto-generated uuid-4 string |
160 +---------------+------------------------------------------------------------+
161 | string | Blank. Also it can be set default values from the system |
162 | | environment variable by mentioning it in the form of : |
165 | | - default_value: ${ENV-VARIABLE-NAME} |
166 +---------------+------------------------------------------------------------+
168 For example to provide the http port of an service, the parameter could be:
171 \- name: service-port
173 description: Service HTTP port.
179 **default_value: 8080**
184 *type* entry allows to set the type of parameter such as boolean, integer, etc.
185 For example to provide the http port of an service, the parameter type could be:
188 \- name: service-port
190 description: Service HTTP port.
200 Platform supports following types of parameter:
204 Any parameter value having a work or a line, string type is appropriate one. By
205 default it is set to blank.
209 Any parameter value having digit such as integers or floating values. For this
210 type of parameter, platform does not set any default value. so while writing
211 the parameter schematics, author should set the *default_value* if needed.
215 To set the value of parameter as JSON. Platform allows to input the JSON values
216 either as direct one line string for simple json or complete file path for
217 providing the complex json value. While user execute the command, based on the
218 value of the JSON parameter, it could given as string or file path.
220 File path could start in the form of file://, http://, ftp://.
224 To set the value of parameter as text. Platform allows to input the text values
225 either as direct one line string for simple text or complete file path for
226 providing the complex text value. While user execute the command, based on the
227 value of the text parameter, it could given as string or file path.
229 File path could start in the form of file://, http://, ftp://.
233 To set the value of parameter as yaml content. Platform allows to input the
234 yaml values as complete file path. While user execute the command, YAML file
235 needs to be created and provided that file's complete path as input value.
237 File path could start in the form of file://, http://, ftp://.
241 This type allows to set the parameter value to either true or false. By
242 default, its value is false, So, when user wants to input the boolean parameter
243 its sufficient to mention the parameter option with out mentioning 'true'.
244 For example, assume that command named 'login' defines the boolean input
245 parameter 'is_secure_connection' to set the service connection is secured or
246 not. For this command, while user input the value for parameter
247 'is_secure_connection', it is sufficient to mention the parameter without
248 passing value. Both of the following command will have same effect:
250 login --is_secure_connection
252 login --is_secure_connection true
256 *uuid* type allows to make the parameter value as UUID. By default platform auto
257 generates uuid-4 formated string.
261 *url* type allows to make the parameter value of URL/URI. Platform does not
262 provide any default value for this type. so Author should provide the
263 *default_value*, if needed during the template is created.
267 *binary* type is very useful to pass the parameter as binary file and user
268 should pass the complete path of the file.
272 To provide the same parameter multiple times array type helps. For example, when
273 the command 'rm' is used, multiple file paths could be provided to remove all of
274 them. In this kind of scenarios, array type supports and each parameter type
279 This is similar to *array* type and only differs the way the values are passed.
280 In this type, values should be in the form of
281 '<parameter-name>=<parameter-value>'
284 Optional and Positional parameters
285 ----------------------------------
286 The input arguments for a given command usually provided with prefixing options
287 names or directly giving the value. Earlier case is called optional arguments
288 and later is called as positional arguments. OCLIP platform supports both the
291 For optional arguments, two type of options are supported:
293 *short option*: option name is usually single character and when user input
294 the corresponding parameter, who will prefix with single dash(-).
296 *long option*: option name is usually more than one characters and when user
297 input the corresponding parameter, who will prefix with double dash(-).
299 For example, the service port could be defined as :
302 \ - name: service-port
304 description: Service HTTP port.
316 **long_option: service-port**
318 When user inputs the service port, it could either of following formats
324 For postional arguments, author should not define both *short_option* and
325 *long_option* and when OCLIP process this template, it will consider as
326 positional arguments. There could be more than one positional arguments could
327 be defined for a command, and OCLIP treats the sequence of the positional
328 parameters defined under *parameters* section is consider as it's position. For
329 example, consider the below example:
354 In this case, param2 and param4 are positional arguments as they are defined
355 with out short and long options. so position of param2 is 1, for param4, it's 2.
356 When user inputs the value as :
358 --param1 v1 -p3 v3 v2 -p5 v5 v4
360 OCLIP platform identifies the positions in sequence. so for param2, value v2
361 will be assigned and for param4, value v4 will be assigned.
363 *NOTE*: User should only concern on the sequence of positional arguments while
364 giving the values and no need to worry about the position at which value should
365 be provided. so all of below sequence will yield the same result.
367 --param1 v1 -p3 v3 **v2** -p5 v5 **v4**
369 **v2** --param1 v1 **v4** -p5 v5 -p3 v3
371 --param1 v1 -p3 -p5 v5 v3 **v2** **v4**
375 OCLIP platform provides following default parameters for every command and
376 author is allowed to customize the inclusion or exclusion of these input
377 parameters for a given command.
384 description: Host user name
388 long_option: host-username
390 default_value: ${OPEN_CLI_HOST_USERNAME}
399 description: Host user password
403 long_option: host-password
405 default_value: ${OPEN_CLI_HOST_PASSWORD}
415 description: Host url
419 long_option: host-url
423 default_value: ${OPEN_CLI_HOST_URL}
429 description: Command help message
441 description: Command service version
453 description: Enable debug output
465 description: Output formats, supported formats such as table, csv, json,
478 description: whether to print all attributes or only short attributes
490 description: whether to print title or not
494 long_option: no-title
502 description: whether to authenticate user or not
510 *NOTE*: no-auth parameter is very helpful to by-pass the login and logout phase
511 of each commands. Please refer *service* section to find more details on login
516 Every command produces the output and *results* section helps to define the
517 details of command outputs such as list of output attributes, the direction in
518 which, result could be printed. More details are as follows.
522 *direction* entity allows to configure the direction in which the results to be
525 * *portrait* : To print the results in two columns. First column is the name of
526 the attribute and second column is the value of the attribute. It's more useful
527 while command does operations like creation of resource, viewing of resources.
529 * *landscape* : To print the results row vise in landscape mode. It's more
530 useful while command does operations like listing of resource.
536 *name* entry uniquely identifies the given attribute. It can be of any
537 alpha-numerical characters and dash(-). For example to print the status of an
538 service, the attribute could be:
541 \- **name: service-status**
545 *description* entry allows to provide the details of the attribute. It's
546 supported in similar approach with command *description* defined in above
547 section. For example service-status could be described as:
550 \- name: service-status
552 **description: Service current status.**
556 *type* entry allows to set the type of attribute such as string, digit, etc.
557 Similar to the parameter's type. currently it supports only string type.
559 For example, service-status could be:
563 \- name: service-status
565 description: Service current status.
571 When a given command produces many results, most of the time no need to print
572 all the attributes. SO OCLIP platform provides this *scope* entry to configure
573 the attribute is printed by default or user should request to print it. So
574 there are two scopes:
576 * *short* : attribute configured with this option will always printed by default
578 * *long* : attriuted configured with this option will get printed only when
579 user inputs the default parameter *long*, defined in *default_parameters*
580 section. So to print all attributes of a command, user will input parameter:
584 A sample attribute for service-status could be:
587 \- name: service-status
589 description: Service current status.
597 OCLIP is enhanced to support REST API based products and *http* section is
598 provided to capture all required details for performing http operation for the
603 Whether its information technology(IT) domain or communication technology(CT)
604 domain, every software product is made of one or more service components. For
605 example, onap has different components like aai, msb, etc and these components
606 provides different kind of resources/features and functionalities.
608 *service* entry allows to mention the details of the given software product's
609 service. This is an section and is having entries defined in below sections.
613 *name* entry allows to configure the service name. For example, to configure
614 service component 'aai' in onap-amsterdam product,
619 *CAUTION*: This entry is very signification to discover this service from the
620 service catalog and name should be matching with the service name registered
625 *version* entry allows to mention the particular version of service for which
626 command is implemented. For example, the service 'aai' in the product
627 'onap-amsterdam' having versions like v11.
632 *CAUTION*: This entry is very signification to discover this service from the
633 service catalog and version should be matching with the service version
634 registered in the catalog.
638 Some software product provides catalog service , where all service of that
639 product could be discovered. While other product does not. OCLIP provides
640 support for both kind of these products to implement commands and *mode*
641 entry allows to configure this mode of operation.
643 CLIP supports in two different mode.
645 In *catalog* mode, OCLIP will discover the service details based on given
646 *name* and *version* from the configured *host-url* parameter. For example,
647 the product 'onap-amsterdam' provides the service 'msb' as the catalog service where
648 all other services will get registered. so OCLIP can discover the given
649 service such as 'aai' from the catalog service 'msb'. In this mode, *host-url*
650 will be configured with the *msb* service url. In this case:
655 *NOTE*: To see the details of *host-url*, refer the section default_parameters
657 In *direct* mode, OCLIP will not perform the discovery operation and consider
658 the given *host-url* as the direct service url. In this case:
663 *NOTE*: To see the details of *host-url*, refer the section default_parameters
669 There are different kind of authentication and authorization approach exist and
670 for OCLIP provides support for following approaches. Based on the approach
671 configured in the template, OCLIP will login before executing the command and
676 In this approach, no login and logout will be performed. This is useful during
677 the development cycle, as well as some services are available in public
678 without authentication of user. In this approach, OCLIP ignores the given
679 *host-username* and *host-password*. So the none auth is defined by:
684 *NOTE*: To see the details of *host-username* and *host-password*, refer the
685 section default_parameters
690 This is HTTP basic authentication approach and given *host-username* and
691 *host-password* values are used to find the hash and use it as Authentication
692 value. So the none auth is defined by:
697 *NOTE*: To see the details of *host-username* and *host-password*, refer the
698 section default_parameters
703 *request* section captures all HTTP request information as:
707 *uri* entry allows to mention the REST API URI. Based on the *service mode*,
708 this entry will vary. * when the mode is 'direct', it should be configured with
709 out *host-url* portion in it. For example, if the REST API is
710 '<host-url>/v1/service1/resource1, in which
712 * /v1/service1 - base path
713 * /resource1 - service resource path.
715 then this entry will be:
718 uri: /v1/service1/resource1
720 when the mode is 'catalog', OCLIP will discover the base path from the
721 'catalog' service, so this entry need to be configured only with resource path
729 *method* entry allows to configure the HTTP methods GET, PUT, POST, DELETE,
730 etc. For example, to get the resource1:
739 *body* entry allows to mention the request body in json format, by default.
740 And OCLIP adds 'application/json' header in the HTTP request. Otherwise, body
741 could have complete path to binary file, in case request body is binary and
742 *multipart_entity_name* should be configured with entity name provided by REST
747 *headers* entry allows to add REST API specific headers. By default OCLIP adds
748 'application/json' as content-type and accept, also it will adds authentication
749 headers such as 'Authentication' in case *auth* is of type 'basic'.
751 For example, to add the sample header :
765 *queries* entry allows to add REST API specific queries. For example, to add
781 *context* entry allows to customize the HTTP request and response processing.
783 Following are the supported customization parameters:
785 *remove_empty_node* : By default, OCLIP does not remove the empty json entries
786 in request body. Otherwise set this entry to true as below.
791 remove_empty_node: true
795 Every REST API has set of success codes and OCLIP will treat the HTTP request
796 made based on the value configured in these http sections, only if
797 *success_codes* contains the HTTP response status code.
801 This section allows to configure the require 'jpath' expression to retrieve the
802 values from the HTTP response body.
804 *NOTE*: Currently only http response body is supported only with json type.
806 For example, if a http response '{"service_status": "green"} then to retrieve
807 the service status and assign to result *attribute* service_status as :
810 service_status: $b{$.service_status}
812 Here, $b is detailed in section 'macros' of this document. and
813 '$.service_status' is jpath expression.
817 This entry allows to keep the sample HTTP response as reference to understand
818 the result_map jpath expressions. OCLIP does not use this entry and is optional.
822 OCLIP platform provides various marcos to fill *http* entries with the value
823 of *parameters*, *headers* , etc Every macro is in the form of <macro name>
824 followed by {<macro details>}Followings are the supported macros:
826 +----------------+------------------------------------------------------------+
827 | Macro | Definitions |
828 +================+============================================================+
829 | ${param-name} | To retrieve the value from parameter named 'param-name' |
830 +----------------+------------------------------------------------------------+
831 | $h{header-name}| To retrieve the value from header named 'header-name' |
832 +----------------+------------------------------------------------------------+
833 | $q{query-name} | To retrieve the value from query named 'query-name' |
834 +----------------+------------------------------------------------------------+
835 | $b{jpath} | To retrieve the value from response body using the 'jpath' |
837 +----------------+------------------------------------------------------------+