Placeholders¶
A placeholder is a replaceable value.
It is typically distinguished by a double set of curly braces - {{placeholder}}
.
Placeholders allow concrete values to be substituted when an element is either created of used. They are found in many technologies. For example, both Postman and IntelliJ's HTTP client use placeholders in their REST API definitions to denote network addresses or identifiers. These values are supplied when the REST request is made through an environment file.
Egeria has support for placeholders both in its configuration documents and its template support that is used when creating metadata.
Placeholder variables¶
The placeholders in the configuration document are called placeholder variables. It is possible to use them when configuring a server:
###
# Set up the common properties needed to call your event bus. The value of ~{kafkaEndpoint}~ is resolved in the
# application.properties file using the `platform.placeholder.variables` property.
POST {{baseURL}}/open-metadata/admin-services/users/{{adminUserId}}/servers/active-metadata-store/event-bus
Content-Type: application/json
{
"producer":
{
"bootstrap.servers":"~{kafkaEndpoint}~"
},
"consumer":
{
"bootstrap.servers":"~{kafkaEndpoint}~"
}
}
~{kafkaEndpoint}~
is provided in the OMAG Server Platform's application.properties
file, like this:
platform.placeholder.variables=\
{\
"kafkaEndpoint" : "localhost:9092"\
}
Notice that placeholder variables use ~{
and }~
as delimiters to avoid confusion with Intellij HTTP variables.
Further information on placeholder variables
- Configuring the OMAG Server Platform for setting up the
additional.properties
file - Configuring OMAG Servers for details of using the placeholder properties.
Placeholder properties¶
Placeholder properties may be added to attributes of the elements that are part of a template. The values to substitute are provided to Egeria when the template is used to create a new open metadata element.
Placeholder properties are particularly useful for elements that need to be unique in the resulting element, such as the qualifiedName attribute, or on attributes that provide a value specific to the new element, such as the address in Endpoint.
For example, the call below is from Automated Curation OMVS. It creates a new metadata element based on the template with the unique identifier passed in the templateGUID
property of the body.
###
# @name createElementFromTemplate
# Create a new element from a template.
POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/automated-curation/catalog-templates/new-element
Authorization: Bearer {{token}}
Content-Type: application/json
{
"templateGUID" : "add guid here",
"isOwnAnchor" : true,
"placeholderPropertyValues" : {
"placeholderPropertyName1" : "placeholderPropertyValue1",
"placeholderPropertyName2" : "placeholderPropertyValue2"
}
}
Below is an example of a call to create an asset using the template:
###
# @name createElementFromTemplate (PostgreSQL Server)
# Create a new element from a template.
POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/automated-curation/catalog-templates/new-element
Authorization: Bearer {{token}}
Content-Type: application/json
{
"templateGUID" : "542134e6-b9ce-4dce-8aef-22e8daf34fdb",
"isOwnAnchor" : true,
"placeholderPropertyValues" : {
"hostIdentifier" : "coconet.com",
"portNumber" : "5432",
"serverName" : "DemoPostgreSQL1",
"databaseUserId" : "psAdmin",
"databasePassword" : "secret"
}
}
{{serverName}}
placeholder property is used in each element to create a unique qualifiedName.
The placeholder properties can be used to make the templates easy to use, removing much of the repetitive creation of property values. The result is a consistent set of elements for the asset.