API-Version
v2
Request-Methode
POST
Operation-ID
container-add-template-component
Adds the Services and Volumes of a Container Template of type component to the Stack. Returns 400 if the Template is not of type component or the user inputs are invalid, 404 if the Template does not exist, and 412 while a template installation of the Stack is still in progress.
Request
Responses
Nutzungsbeispiele
$ curl \
--fail \
--location \
-X POST \
-d '{"templateConfig":{"templateId":"postgres","userInputs":[{"name":"HOST","value":"postgres.example.org"}]}}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/stacks/f0f86186-0a5a-45b2-aa33-502777496347/actions/add-template-component
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";
const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.container.addTemplateComponent({
"stackId": "f0f86186-0a5a-45b2-aa33-502777496347",
"data": {
"templateConfig": {
"templateId": "postgres",
"userInputs": [
{
"name": "HOST",
"value": "postgres.example.org"
}
]
}
}
});
assertStatus(response, 204);
use \Mittwald\ApiClient\Generated\V2\Clients\Container\AddTemplateComponent\AddTemplateComponentRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\Container\AddTemplateComponent\AddTemplateComponentRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// AddTemplateComponentRequestBody to learn how to construct a valid instance
$body = new AddTemplateComponentRequestBody(/* TODO: ... */);
$request = (new AddTemplateComponentRequest(
stackId: "f0f86186-0a5a-45b2-aa33-502777496347",
body: $body
));
$response = $client->container()->addTemplateComponent($request);
var_dump($response->getBody();