Re: Right way to get file version with Data Plane API?

2020-09-21 Thread Илья Шипицин
version is required if you wish to perform complex change, "transaction" in
terms of dataplane api.
for simple change indeed it is not required.

пн, 21 сент. 2020 г. в 14:29, Jonathan Matthews :

> I’ve not used the API yet, but my reading of those docs, alongside some
> previous experience, suggests to me that the version should br an entirely
> user-specified, opaque-to-haproxy string, whose purpose is to avoid stale
> config writes from concurrent clients.
>
> However, the fact that the version seems to be required outside of
> transactions, and indeed that changes outside transactions are even
> possible, makes me think I’ve got that wrong.
>
> I agree with OP: there should be a “show me the current version ID”
> endpoint. I don’t see how the best (apparent!) candidate (
> /v2/services/haproxy/configuration/raw ) can be used to achieve this, as it
> also requires a version to be provided.
>
> I’m interested in what folks suggest :-)
>
> J
>
> On Mon, 21 Sep 2020 at 09:55, Ricardo Fraile  wrote:
>
>> 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" ?
>>
>>
>>
>> --
> Jonathan Matthews
> https://jpluscplusm.com
>


Re: Right way to get file version with Data Plane API?

2020-09-21 Thread Илья Шипицин
you can get version by REST api. here's an example in PowerShell

*$version* = Invoke-RestMethod -Method 'GET' -Uri
'http://xxx.xxx.xxx:/v1/services/haproxy/sites' -Credential $Cred
-AllowUnencryptedAuthentication

$transaction = Invoke-RestMethod -Method 'POST' -Uri
('http://xxx.xxx.xxx:/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:/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 :

> 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" ?
>
>


Re: Right way to get file version with Data Plane API?

2020-09-21 Thread Jonathan Matthews
I’ve not used the API yet, but my reading of those docs, alongside some
previous experience, suggests to me that the version should br an entirely
user-specified, opaque-to-haproxy string, whose purpose is to avoid stale
config writes from concurrent clients.

However, the fact that the version seems to be required outside of
transactions, and indeed that changes outside transactions are even
possible, makes me think I’ve got that wrong.

I agree with OP: there should be a “show me the current version ID”
endpoint. I don’t see how the best (apparent!) candidate (
/v2/services/haproxy/configuration/raw ) can be used to achieve this, as it
also requires a version to be provided.

I’m interested in what folks suggest :-)

J

On Mon, 21 Sep 2020 at 09:55, Ricardo Fraile  wrote:

> 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" ?
>
>
>
> --
Jonathan Matthews
https://jpluscplusm.com


Re: Right way to get file version with Data Plane API?

2020-09-21 Thread Ricardo Fraile
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" ?




Re: Right way to get file version with Data Plane API?

2020-09-18 Thread Илья Шипицин
what do you mean by "file version" ?

пт, 18 сент. 2020 г. в 12:57, Ricardo Fraile :

> Hello,
>
> Getting the file version seems to be one of the first things to do at
> the beginning of using the API, but I can't find an easy and clear way
> to get it.
>
> It seems extrange that that thing doesn't have a target url to get it.
> Maybe I'm wrong, but I get it with the raw output:
>
> # curl --user user1:password1
> http://127.0.0.1:/v2/services/haproxy/configuration/raw
>
> Is there an other right way to get it?
>
>
> Thanks,
>
>


Right way to get file version with Data Plane API?

2020-09-18 Thread Ricardo Fraile

Hello,

Getting the file version seems to be one of the first things to do at 
the beginning of using the API, but I can't find an easy and clear way 
to get it.


It seems extrange that that thing doesn't have a target url to get it. 
Maybe I'm wrong, but I get it with the raw output:


# curl --user user1:password1 
http://127.0.0.1:/v2/services/haproxy/configuration/raw


Is there an other right way to get it?


Thanks,