-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-EtcdValue.ps1
35 lines (28 loc) · 963 Bytes
/
Set-EtcdValue.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function Set-EtcdValue {
param(
[Parameter(Mandatory=$true)]
[Alias("Server")]
[string]$EtcdServer,
[Parameter(Mandatory=$true)]
[string]$Key,
[Parameter(Mandatory=$true)]
[string]$Value
)
# Convert the key and value to base64
$Base64Key = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Key))
$Base64Value = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Value))
# Create the JSON payload
$Payload = @{
"key" = $Base64Key
"value" = $Base64Value
} | ConvertTo-Json
# Set the headers
$Headers = @{
"Content-Type" = "application/json"
"Authorization" = "tlXjxEsDEaftvVcl.13"
}
# Send the request to the etcd server
$Response = Invoke-RestMethod -Uri "$EtcdServer/v3/kv/put" -Method Post -Body $Payload -Headers $Headers
# Return the response
return $Response
}