The following parameters section explains how to define a custom data source in the StyleBook definition. It allows StyleBook users to select a specific item of a collection.
parameters:
- name: selected-app-vserver
label: Select a collection from the datasource
type: datum
required: true
data-source:
type: Environment
collection: App-virtual-servers
In this example, the datum parameter is used to define the custom data source. It uses the Production data source to retrieve data from the App-virtual-servers collection schema.
In the Environment data source type, to access the protocol from the App-virtual-servers collection, use the following expression:
$parameters.selected-app-vserver.attributes.Protocol
Example snippet:
components:
- name: lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.selected-app-vserver.attributes.Name
ipv46: $parameters.selected-app-vserver.attributes.IPv46
port: $parameters.selected-app-vserver.attributes.Port
servicetype: $parameters.selected-app-vserver.attributes.Protocol
When you define a collection type in the parameters section, the StyleBook users can select the data source and collection.
Selecting multiple items from a collection:
The following parameters section allows StyleBook users to select multiple items of a collection.
parameters:
- name: selected-app-vservers
label: Select app-vservers from the collection
type: datum[]
required: true
data-source:
type: Environment
collection: App-virtual-servers
In this example, the datum parameter is used to define the custom data source array. User can select one or more items from ‘App-virtual-servers’ collection from a single data source or across data sources.
The code snippet below depicts the way to access selected items and its attributes.
components:
-
name: lbvserver-comp
type: ns::lbvserver
repeat:
repeat-list: $parameters.selected-app-vservers
repeat-item: vserverObj
properties:
name: $vserverObj.attributes.Name
ipv46: $vserverObj.attributes.IPv46
port: $vserverObj.attributes.Port
servicetype: $vserverObj.attributes.Protocol
Filtering Collection data:
The following parameters section explains how to specify filters on a custom data source collection in the StyleBook definition. It allows StyleBook users to select a specific item from a filtered collection.
parameters:
- name: selected-app-vserver
label: Select a collection from the datasource
type: datum
required: true
data-source:
type: Environment
collection: App-virtual-servers
collection-filters:
Protocol: SSL
In this example, the datum parameter is used to define the custom data source. It uses the data source of type Environment to retrieve filtered data from the App-virtual-servers collection schema.
After the StyleBook user selects a virtual server, any attribute of the selected item can be accessed the same way as explained in the previous section.