APIIDA API Gateway Manager
Deploy a API with Service Templates via API
To get a basic understanding of this function you should first read Service Templates .
Create a service template
First, we create a service template via the API using the examples from Service Templates .
To create, the policy template must be encoded with base64 and the JSON template must be escaped.
Here the body to copy
{
"name": "some Name",
"policyTemplate": "PHdzcDpQb2xpY3kgeG1sbnM6TDdwPSJodHRwOi8vd3d3LmxheWVyN3RlY2guY29tL3dzL3BvbGljeSIgeG1sbnM6d3NwPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDAyLzEyL3BvbGljeSI+CiAgICA8d3NwOkFsbCB3c3A6VXNhZ2U9IlJlcXVpcmVkIj4KICAgICAgICA8TDdwOkNvbW1lbnRBc3NlcnRpb24+CiAgICAgICAgICAgIDxMN3A6Q29tbWVudCBzdHJpbmdWYWx1ZT0ie3tjb21tZW50fX0ge3tkYXRlfX0ge3tzb21lRWxlbWVudH19Ii8+CiAgICAgICAgPC9MN3A6Q29tbWVudEFzc2VydGlvbj4KCiAgICAgICAgPCEtLSB7e3VzZVNTTH19IC0tPgogICAgICAgIDxMN3A6Q29tbWVudEFzc2VydGlvbj4KICAgICAgICAgICAgPEw3cDpDb21tZW50IHN0cmluZ1ZhbHVlPSJTU0wiLz4KICAgICAgICA8L0w3cDpDb21tZW50QXNzZXJ0aW9uPgogICAgICAgIDwhLS0ge3svdXNlU1NMfX0gLS0+CgogICAgICAgIDwhLS0ge3thdXRoPWJhc2ljfX0gLS0+CiAgICAgICAgPEw3cDpDb21tZW50QXNzZXJ0aW9uPgogICAgICAgICAgICA8TDdwOkNvbW1lbnQgc3RyaW5nVmFsdWU9IkF1dGggQkFTSUMiLz4KICAgICAgICA8L0w3cDpDb21tZW50QXNzZXJ0aW9uPgogICAgICAgIDwhLS0ge3svYXV0aD1iYXNpY319IC0tPgoKICAgICAgICA8IS0tIHt7YXV0aD1jZXJ0fX0gLS0+CiAgICAgICAgPEw3cDpDb21tZW50QXNzZXJ0aW9uPgogICAgICAgICAgICA8TDdwOkNvbW1lbnQgc3RyaW5nVmFsdWU9IkF1dGggQ0VSVCIvPgogICAgICAgIDwvTDdwOkNvbW1lbnRBc3NlcnRpb24+CiAgICAgICAgPCEtLSB7ey9hdXRoPWNlcnR9fSAtLT4KICAgICAgICAKICAgIDwvd3NwOkFsbD4KPC93c3A6UG9saWN5Pg==",
"templateSpec": "{\r\n \"$schema\": \"https:\/\/apiida.com\/schemas\/layer7-template\",\r\n \"$version\": \"1.0\",\r\n \"name\": \"Basic template example\",\r\n \"description\": \"This is a basic template to demo service templates\",\r\n \"blocks\": [\r\n {\r\n \"name\": \"useSSL\",\r\n \"description\": \"This API will only be available via SSL \/ https\",\r\n \"group\": \"Authentication\"\r\n },\r\n {\r\n \"name\": \"auth\",\r\n \"description\": \"Means of authentication\",\r\n \"options\": [\r\n {\r\n \"value\": \"basic\",\r\n \"text\": \"http Basic Authentication\"\r\n },\r\n {\r\n \"value\": \"cert\",\r\n \"text\": \"Client Certificate\"\r\n }\r\n ],\r\n \"group\": \"Authentication\"\r\n },\r\n {\r\n \"name\": \"validateBackendResults\",\r\n \"description\": \"Validate backend results against the Swagger-File\"\r\n }\r\n ],\r\n \"variables\": [\r\n {\r\n \"name\": \"comment\",\r\n \"description\": \"This value is inserted into the policy\",\r\n \"type\": \"string\",\r\n \"required\": true\r\n },\r\n {\r\n \"name\": \"date\",\r\n \"description\": \"Example for another datatype\",\r\n \"type\": \"date\",\r\n \"required\": true,\r\n \"group\": \"Authentication\"\r\n },\r\n {\r\n \"name\": \"someElement\",\r\n \"description\": \"Select something\",\r\n \"type\": \"select\",\r\n \"required\": false,\r\n \"options\": [\r\n {\r\n \"value\": \"A\",\r\n \"text\": \"This inserts A\"\r\n },\r\n {\r\n \"value\": \"B\",\r\n \"text\": \"This inserts B\"\r\n }\r\n ]\r\n }\r\n ]\r\n}"
}
The answer is the id of the created service template.
Deploying a service with the created service template
Required variables must be entered in the body like target or name. For the blocks a "block_" must precede.
Here the body to copy
{
"target": "L7 10444",
"name": "my cool new Service",
"urlPattern": "/myCoolNewService",
"block_auth": "cert",
"comment": "a comment",
"date": "25.04.2023",
"verbs": [
"GET"
]
}