you can get version by REST api. here's an example in PowerShell
*$version* = Invoke-RestMethod -Method 'GET' -Uri
'http://xxx.xxx.xxx:5555/v1/services/haproxy/sites' -Credential $Cred
-AllowUnencryptedAuthentication
$transaction = Invoke-RestMethod -Method 'POST' -Uri
('http://xxx.xxx.xxx:5555/v1/services/haproxy/transactions?version={0}'
-f *$version._version*) -Credential $Cred
-AllowUnencryptedAuthentication
$Backend = @"
{
"name": "git_xxx_ru_https_backend",
"mode": "http"
}
"@
Invoke-RestMethod -Method 'POST' -ContentType 'application/json' -Uri
('http://xxx.xxx.xxx:5555/v1/services/haproxy/configuration/backends?transaction_id={0}'
-f $transaction.id) -Body $Backend -Credential $Cred
-AllowUnencryptedAuthentication
$Server1 = @"
{
"id": 1, "name": "server1", "address": "xxx.xxx.xxx.xxx", "port":
80, "check": "enabled"
}
"@
пн, 21 сент. 2020 г. в 13:55, Ricardo Fraile <[email protected]>:
> For example, to start a new transaction, as the documentation [1]
> points:
>
> version / required
> Configuration version on which to work on
>
> Or the blog post about it [2]:
>
> Call the /v1/services/haproxy/transactions endpoint to create a new
> transaction. This requires a version parameter in the URL, but the
> commands inside the transaction don’t need one. Whenever a POST, PUT, or
> DELETE command is called, a version must be included, which is then
> stamped onto the HAProxy configuration file. This ensures that if
> multiple clients are using the API, they’ll avoid conflicts. If the
> version you pass doesn’t match the version stamped onto the
> configuration file, you’ll get an error. When using a transaction, that
> version is specified up front when creating the transaction.
>
> What is the right way to get the version stamped on the configuration
> file?
>
> Thanks,
>
> [1] -
>
> https://www.haproxy.com/documentation/dataplaneapi/latest/#operation/startTransaction
> [2] - https://www.haproxy.com/blog/new-haproxy-data-plane-api/
>
>
> > what do you mean by "file version" ?
>
>