0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

XIQ-C hostname ワンライナー

Posted at
curl -s -k -H "Authorization: Bearer <TOKEN>" "https://<XIQC_HOST>:5825/management/v1/aps/<AP_SERIAL>" \
| jq --arg hn "<NEW_HOSTNAME>" '.hostname=$hn | (if .apName? then .apName=$hn elif .name? then .name=$hn else . end)' \
| curl -s -k -X PUT "https://<XIQC_HOST>:5825/management/v1/aps/<AP_SERIAL>" -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" --data @- -w " <AP_SERIAL> -> <NEW_HOSTNAME> HTTP:%{http_code}\n" -o NUL

何をしている?(3段ロケット)
GET:対象APの“完全な現在設定”を取得

curl -s -k -H "Authorization: Bearer <TOKEN>" \
"https://<XIQC_HOST>:5825/management/v1/aps/<AP_SERIAL>"

-s … silent(進捗バーなどを出さない)
-k … 証明書検証を飛ばす(自己署名環境向け。信頼済みなら外す)
-H "Authorization: Bearer " … 事前取得トークンで認可
返り値は APオブジェクトのJSON(XIQ-Cは部分更新不可なので“完全JSON”が必要)

整形(置換):hostname と「表示名」を安全に差し替え

| curl -s -k -X PUT "https://<XIQC_HOST>:5825/management/v1/aps/<AP_SERIAL>" \
    -H "Authorization: Bearer <TOKEN>" \
    -H "Content-Type: application/json" \
    --data @- \
    -w " <AP_SERIAL> -> <NEW_HOSTNAME> HTTP:%{http_code}\n" -o NUL

--data @- … 標準入力(=jqの出力JSON)をそのまま送る
-w " ... HTTP:%{http_code}\n" … HTTPコードを末尾に表示(200 なら成功目安)
-o NUL … レスポンスボディは捨てる(Windowsの /dev/null)

出力の読み方

末尾に HTTP:200(もしくは 204)が出れば成功が目安。

念のため確認:

curl -s -k -H "Authorization: Bearer <TOKEN>" "https://<XIQC_HOST>:5825/management/v1/aps/<AP_SERIAL>" | jq -r '.apName?, .name?, .hostname'
| jq --arg hn "<NEW_HOSTNAME>" ".hostname=$hn | .apName=$hn" ^
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?