stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
224 stars 117 forks source link

feature: support set if-Machine header when update BiosAttributes #175

Closed Sn0rt closed 2 years ago

Sn0rt commented 2 years ago

Closes: #174

and self-test

will take a query /redfish/v1/Systems/1/Bios/Setting for the Etag

GET /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
Host: 192.168.142.53
User-Agent: gofish/1.0
Connection: close
Accept: application/json
Content-Type: application/json
Cookie: sessionKey=xx
X-Auth-Token: xx
Accept-Encoding: gzip

HTTP/1.1 200 OK
Connection: close
Content-Length: 536
Allow: GET,PATCH,POST
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' wss://*:*; img-src 'self' data:; frame-src 'self'; font-src 'self' data:; object-src 'self'; style-src 'self' 'unsafe-inline'
Content-Type: application/json;charset=utf-8
Date: Mon, 23 May 2022 07:20:01 GMT
Etag: W/"93227b24"
Expires: 0
Link: </redfish/v1/SchemaStore/en/Bios.json>;rel=describedby
Odata-Version: 4.0
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{"@odata.context":"/redfish/v1/$metadata#Systems/Members/1/Bios/Settings/$entity","@odata.id":"/redfish/v1/Systems/1/Bios/Settings","@odata.type":"#Bios.v1_0_0.Bios","Id":"Settings","Name":"BIOS Configuration Pending Settings","AttributeRegistry":"BiosAttributeRegistry.8.0.2","Attributes":{"PXE3Setting":"Disabled"},"Actions":{"Oem":{"Huawei":{"#Settings.Revoke":{"target":"/redfish/v1/Systems/1/Bios/Settings/Actions/Oem/Huawei/Settings.Revoke","@Redfish.ActionInfo":"/redfish/v1/Systems/1/Bios/Settings/SettingsRevokeActionInfo"}}}}}
PATCH /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
Host: 192.168.142.53
User-Agent: gofish/1.0
Connection: close
Content-Length: 41
Accept: application/json
Content-Type: application/json
Cookie: sessionKey=xxx
If-Match: W/"93227b24"
X-Auth-Token: xxx
Accept-Encoding: gzip

{"Attributes":{"PXE3Setting":"Disabled"}}
HTTP/1.1 200 OK
Connection: close
Content-Length: 536
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' wss://*:*; img-src 'self' data:; frame-src 'self'; font-src 'self' data:; object-src 'self'; style-src 'self' 'unsafe-inline'
Content-Type: application/json;charset=utf-8
Date: Mon, 23 May 2022 07:20:01 GMT
Etag: W/"93227b24"
Expires: 0
Odata-Version: 4.0
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{"@odata.context":"/redfish/v1/$metadata#Systems/Members/1/Bios/Settings/$entity","@odata.id":"/redfish/v1/Systems/1/Bios/Settings","@odata.type":"#Bios.v1_0_0.Bios","Id":"Settings","Name":"BIOS Configuration Pending Settings","AttributeRegistry":"BiosAttributeRegistry.8.0.2","Attributes":{"PXE3Setting":"Disabled"},"Actions":{"Oem":{"Huawei":{"#Settings.Revoke":{"target":"/redfish/v1/Systems/1/Bios/Settings/Actions/Oem/Huawei/Settings.Revoke","@Redfish.ActionInfo":"/redfish/v1/Systems/1/Bios/Settings/SettingsRevokeActionInfo"}}}}}

Signed-off-by: Guohao Wang wangguohao.2009@gmail.com

stmcginnis commented 2 years ago

Thanks! I am traveling for a little over a week yet, but I will take a closer look at this when I get back. Thanks for working on this!!