|
Post by jegathees on Sept 4, 2023 6:27:13 GMT
Hi All , I have Small doubt in Redfish Property , In the Chassis resource, I am currently attempting to include a string property with the label "Email" Inside OEM, For example : "Email": [ " [email protected]", " [email protected]", " [email protected]", " [email protected]" ] I am able to get , set and patch this property . is possible to Delete particular mail id's ?
Kindly help here , Thanks in advance
|
|
|
Post by mraineri on Sept 5, 2023 13:02:29 GMT
Yes, in arrays, you can delete members. The clause "PATCH on array properties" in the Redfish Specification contains the full details.
When you're PATCHing an array, the values null and {} are used to control whether you want to delete a member or leave a member as-is. So, if you want to delete the first member, but leave the remaining three alone, you would provide "Email": [ null, {}, {}, {} ] in the PATCH request.
|
|
|
Post by jegathees on Sept 11, 2023 5:17:10 GMT
This is Really fine Mraineri, But is possible to use a delete call to delete the member of the array properties..?
|
|
|
Post by mraineri on Sept 11, 2023 12:39:53 GMT
No, DELETE in HTTP semantics is to delete the entire resource. Deleting an array member is modifying an existing resource, which would equate to a PATCH operation.
|
|
|
Post by jegathees on Sept 12, 2023 9:37:05 GMT
okay, if i have stored 20 mail id's in an array of string property , i want to delete a 2 mail id's means how it possible ?
|
|
|
Post by mraineri on Sept 12, 2023 12:52:11 GMT
So, let's give a concrete example. Let's say this is your resource array of strings with 10 entries (I lowered the count just so the example is easier to look at).
{ "Emails": [ "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]" ], <Other properties in the resource> } Let's say the user wants to remove the email addresses at indexes 5 and 7. In the PATCH request, they would use null for the those two indexes, and {} for the rest to indicate "leave this alone". So, the PATCH request body would look like this: { "Emails": [ {}, {}, {}, {}, {}, null, {}, null, {}, {} ] } After that operation is complete, " [email protected]" and " [email protected]" are no longer in the list, and the remaining array entries shift up to fill in the empty index slots.
|
|
|
Post by jautor on Sept 12, 2023 14:44:22 GMT
Note that you can always just replace the entire array contents by PATCH the entire array with the new contents. The empty object and null options are there to allow humans doing scripts to avoid mistakes in re-typing the entire array. But if your program is modifying the array itself, just doing the full array PATCH with the new values is easy. From Mike's example, if you just PATCH: { "Emails": [ "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]" ] } You'll get the same result as above: { "Emails": [ "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]" ], <Other properties in the resource> } Jeff
|
|
|
Post by mraineri on Sept 12, 2023 15:19:37 GMT
Good point; I forgot about that method too!
|
|