Reset environments to their template
Makes the named stages of each target environment follow the template again, replacing what the environment holds for them. Send dry_run true first to see what would change; a reset that includes production environments is then confirmed with confirm_production true and confirm_count, the dry run's production_count.
- Needs
execas well: A target environment gains a command it does not run now (never for a dry run).
Path parameters
The id of a company you belong to or manage. Digits only. At least 1.
The platform the template is for, such as magento2, laravel or wordpress. The list answers the ones your company can have.
Body
The dry run's production_count. At least 0.
Answer what would change for each target and write nothing.
Up to 200 items.
Fields of each item
At least 1.
The stages to reset, or ["all"]. Up to 4 items.
builddatabasepost_deploysettingsallReturns
200 The targets and, when the reset was made, what was written.
Fields of the 200 answer
The number to send as confirm_count.
Targets that cannot be reset, each with why. A dry run lists them; a reset that names one is refused template_refused_on.
Fields of each item
Such as not_reached, pipeline_classic, pipeline_review_pending or pipeline_locked.
At least 1.
Fields of each item
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | Send a valid token as Authorization: Bearer <token>. |
403 | company_unavailable | Your company is unavailable. |
403 | scope_required | Use a token with the scope named in scope. |
403 | forbidden | The person is not allowed to do this. |
403 | two_factor_required | Turn on two-factor on your account, then send again. |
404 | feature_off | This feature is not on for your organisation yet. |
409 | reach_changed | The production environments of this reset have changed. Review the selection again. |
422 | confirm | The action needs an explicit confirmation field. Ask the person, then send it. |
422 | invalid | Fix the field named in field; errors says why. |
422 | template_refused_on | Some environments cannot be reset. Deselect them, then reset the rest. |
429 | rate_limited | Wait for the seconds in Retry-After. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
curl -X POST https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset \
-H "Authorization: Bearer $COREFINITY_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"confirm_count": 1,
"confirm_production": true,
"targets": [
{
"site_id": 1042,
"stages": [
"all"
]
}
]
}'use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('COREFINITY_TOKEN'))
->acceptJson()
->post('https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset', [
'confirm_count' => 1,
'confirm_production' => true,
'targets' => [
[
'site_id' => 1042,
'stages' => [
'all',
],
],
],
]);
$data = $response->json();const res = await fetch('https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
confirm_count: 1,
confirm_production: true,
targets: [
{
site_id: 1042,
stages: [
'all',
],
},
],
}),
});
// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);import os
import requests
res = requests.post(
"https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset",
headers={
"Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
"Accept": "application/json",
},
json={
"confirm_count": 1,
"confirm_production": True,
"targets": [
{
"site_id": 1042,
"stages": [
"all",
],
},
],
},
)
data = res.json() if res.content else None{
"dry_run": true,
"production_count": 1,
"refused": [],
"targets": [
{
"production": true,
"site_id": 1042,
"stages": [
"post_deploy"
]
}
],
"written": null
}{
"message": "Unauthenticated."
}{
"code": "company_unavailable",
"message": "Your company is unavailable.",
"reason": "company_unavailable"
}{
"code": "feature_off",
"message": "Not found.",
"reason": "feature_off"
}{
"code": "reach_changed",
"message": "The production environments of this reset have changed. Review the selection again.",
"production_count": 1,
"reason": "reach_changed"
}{
"code": "confirm",
"errors": {
"confirm_count": [
"Type the number of production environments to confirm the reset."
]
},
"message": "Type the number of production environments to confirm the reset.",
"production_count": 1,
"reason": "confirm"
}{
"code": "rate_limited",
"message": "Too many requests. Try again in 60 seconds.",
"reason": "rate_limited",
"retry_after_seconds": 60
}Try it is off for this endpointIt overwrites data that cannot be brought back. Copy the request and run it yourself when you are sure.