From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.67]) by mx.groups.io with SMTP id smtpd.web12.29548.1660746932991992679 for ; Wed, 17 Aug 2022 07:35:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ami.com header.s=selector1 header.b=BPCm37rB; spf=pass (domain: ami.com, ip: 40.107.101.67, mailfrom: igork@ami.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kUK7/jgehQydpGV8phZ1kRwfVGYM0STKA7zKhiAtuDg94hec3QLAIDRb4s2g8i77j2gkxJ5XqAwiY3TBjBmXuEwwbX174IFdt4Xy6YeXfTQgANhScRFSzPbZlYjyWZWp4jZupWsUDtLTSqoAB/5JnaK6qGMocwgF1PY7vQdW6AlHVL+MqMFjLTpyRm/ZbA6nCAM9LBgYytQMSiIh6glCl480e1S1oSNGrajUUVsPxjyIMH5n9tlu9cKAW2y4YVgSwJXB2Gpe10YpQBySyUAzRFee9VD3FsJsO8xEYlMW+6z6ShB+WY6I51ihvXIJAarIjyLDsbPF5WK1sl+T3Kd+uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0A6k49VjZbvTnpoeeTaCx/wxBaJho7fyKyjHfFVdxpY=; b=hxucI8BRvVm8WdJoO0NEKoa3Rs69dbpxvF9BNpzBsEL0mLR9f2fR3+61AqgLI0mx9CzVrzscHVqC5Vs2zkBf4OYjD6pxjxcCYRSVR6aYqW5g00jg7a7rMdz2y4XmsFfmdfA/+RkJxEZTWboQb8dKnDUpdxAc/uhTJ92jq86dLtTA2MNk2xjVMPYkOjfVvvbpz8RhzbbH4cN6q6rPsuu2GB8UkMoxX7yr1Gfb9XtEo/NSpaJ0RPXDE6LINyYn5UiXAMWlqoE1QotbdXeAQRLJSElzsFGHzpaUgb0AmoRwndVsVOJisM6zppCLsgknsWcxj5XlyMqjf1JTafE44EWrzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ami.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0A6k49VjZbvTnpoeeTaCx/wxBaJho7fyKyjHfFVdxpY=; b=BPCm37rBG+wgoYFaZoRFbe/y4yPzQmo76sx/zwYl0iYPvN+u562cr6FNhQB1kLG9su097c2pl2zZUp+Zn54Djn/39ioQch0NGw7EntaLHb5tnBnhs/ZQ2kaQX+JpraDmgfZw3ILDZpyFa07vVYTIrW+L/Sw8H54CkP4OKEFx/Ec= Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Wed, 17 Aug 2022 14:35:29 +0000 Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::3007:4429:73e9:503e]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::3007:4429:73e9:503e%3]) with mapi id 15.20.5525.011; Wed, 17 Aug 2022 14:35:29 +0000 From: "Igor Kulchytskyy" To: "Chang, Abner" , "devel@edk2.groups.io" CC: "nickle.wang@hpe.com" Subject: Re: [PATCH 3/3] RedfishPkg: The functions for Redfish requests do not fully complied with specification Thread-Topic: [EXTERNAL] RE: [PATCH 3/3] RedfishPkg: The functions for Redfish requests do not fully complied with specification Thread-Index: AQHYsQ8HXswPiaN2H0Ouzm4TF4OdNK2yeF1AgACj/TA= Date: Wed, 17 Aug 2022 14:35:29 +0000 Message-ID: References: <1660613098-15792-1-git-send-email-igork@ami.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-08-17T04:00:10Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=a2dbdfd8-7604-4506-bdd0-e579ece3a3eb; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ami.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 06b3bbac-0b12-4b51-fcf9-08da805dbbae x-ms-traffictypediagnostic: BYAPR10MB3239:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: peyXgalo7Q3Ica9/1eWcgX7J+Gzf+wJTIY7B3Cfg17EW3bA6frOf27CGIEkaBSFEE7/YR3sHIKIqpOzcCZby3FcqXxuZa3iARizaVK/KLG1OOWuwQtDbhPv5NHYwjqzbNLVwTm45SDOI39P+3ubNpIxyTjGfH8qLVwUpVHOEn/s0HDW/ro9x8WpXBVo2eH89oBXNfWgWAF7MfoEUAHVqVS+FoNPSYGGkFN1uOw1uGsM4pL8BtcztFrN2bt3UgegiCcXG8oIv5rZgXgmsun4i9QCcDGZenbV8vWA3Sp/f4AxA+KyxnIEA7j3t7EXj1ATcdl6gpTxwEiGW9yy+KjOTXH5ElrrmraDmxPP7l8Xb0H78c9iulH3CSWMPcg4dqXVe7T/gGbf/6L68ejLJ/h2SMxQMr9F+1E9J6qnEDnCftikzN4WhiOkVOOIz/iS0QpFFiOSDQA771dKcUNWGlyCa/7+cS6TaTDCgTlzyFsFZCpVuequp62OjC6GEL9qLLa9DNhVePBuG1KOGZjJot9YOLlQVgk7lAxZ17+Ap6E109MTX3TtpAgFjbMxEgkrgCPnU6pSAKzkKlTVY8r86jNwB8FdSk6Is87iZVG9no3/kr/UOnxIc+eLIFZJfa7y+I+ToBcHQysCJpwg3XVh2YyellzJB8EBFzpHe0VCdzDQBzLL9j963oi2awJNy87msQJjpKjVluekisO/ok8RjNDz1HGAzo+1yZUGaUD+Xfxh3aV5w3xQGESK/FAXUk0Lvr1VeaRrBO87G3T7Cyfl+DQsCKSTkBa5x5nCaej3ym3Gr9BxUP6djUC37uavgnmYjm+Dn x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5185.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(39850400004)(376002)(346002)(396003)(136003)(366004)(83380400001)(4326008)(7696005)(41300700001)(71200400001)(110136005)(478600001)(2906002)(66556008)(8676002)(55016003)(30864003)(66476007)(64756008)(52536014)(5660300002)(316002)(66446008)(76116006)(66946007)(8936002)(122000001)(53546011)(33656002)(186003)(9686003)(26005)(38070700005)(38100700002)(86362001)(6506007)(40140700001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?enSK77z5Qs/952RrKbBYZ54lFiXogZSH8dWkdMjjii5NP3qzvBNbUZYwhnNU?= =?us-ascii?Q?GLKwQQrIhz8dUWB6XazEw9KYqwyYush//ImqA8RAYxm2xLof/ykt7pAF9IaS?= =?us-ascii?Q?Xz5pWNoj/AfluhrBJydFQarpnd6eLelXF8wdMUQeSaebCKHPDqW6wd1SM+ox?= =?us-ascii?Q?ORFbp/ZDLDrwulXGg1Eq89ljyxVCNb8aztaR42YCW39+KYldtiRCdIH90Cyt?= =?us-ascii?Q?G2BjEXGe31jVon0f2H+3hxlfz4RQpYuBoJbPJQD1LYG63lZmYa5HO4+CcPoz?= =?us-ascii?Q?hClTpOTt0+/q1PPepDGwuaIDiuqDFVB3LecGAJ49XgaEaCSOrxgMKdREpdkJ?= =?us-ascii?Q?80OfAKTB1Ug5QGyItCguYPZFEZFEK1zZ+D4zd0LEUqp5+51e0HHV312ER2Ik?= =?us-ascii?Q?xhenzLNlSUudeswh0Z9A5uoAtHcUTh3AYCqoMM8mru5mvqomGhT1XB7K2dWG?= =?us-ascii?Q?B0VqSj/9vj1TDN3dLLatJHgY5ZddX6YZ8oI7OhXjK0LxXfc3acnY+PEpgvDI?= =?us-ascii?Q?mVYe0ZRwgEfOF5fRNH29cX4v/1GGg8PW2dBLaftLQKqqJgdNDJlpvI53rj8s?= =?us-ascii?Q?XCcR7sXN7A8XQvIveZraXOEeN3Ww/sh/+dA3AidsasY6dHxLoe4w0uyx/5wm?= =?us-ascii?Q?PjW3pZbra3+BSb4cJIwry858DqRJzQtuMQfUHtqV3EuehX4jUYCo7OpXjEmM?= =?us-ascii?Q?RQmpAu0nYb9yR+nf/SgaRgLuCDlkjwBYy5fnkJRYvK8RQl+immza/CsUrgUr?= =?us-ascii?Q?IfKzk/hJmPofMDP+oZi7wcXsYXAWoWgvA0Mmcy+F+FvBMzs6ZX/qv0OwLw//?= =?us-ascii?Q?/AmDkuvOjx7HkkHzFZ0TwOABLyS+bC/D76cpPzrnJsEZ3eGarQzr6AZCpTay?= =?us-ascii?Q?v8uWCxm5zDlruOPGBJIREOifwdi3j7pO7N+Tc0rbrZYMkV8Xx+7n1V13aC4w?= =?us-ascii?Q?WBu6anlyBjn46l+xsBnIszs6zRrY64euyV6ANhBBplhiPl0kPXfFZfz1W9m/?= =?us-ascii?Q?iwv+eDzyRkt81VquU3I42dWfFfIqticlqTrg5OBwzEZxU4GFQQX1NOvSS1+k?= =?us-ascii?Q?TfLMhhHGLdtWZ5mnDBZCf/eajN6j7mGVO3XYgBtYzJULJGy7tJer4eeXKDHu?= =?us-ascii?Q?CGZVUyqsCXya45guyajXXBDSlLK2JzIwa0LY/CnXDV/9onjbYxOZ5DO+wMVE?= =?us-ascii?Q?QduEohaduttMi7b5pzEE0bgVjrBZRHFCFjODXVye/wbRgVFShB6zElFbK30R?= =?us-ascii?Q?jJjSEBZeffSI/NhsV/iHJA+rHLES7ca8JA0yjBcuFmQTVKuNZEX5JjmISFTE?= =?us-ascii?Q?mzadrDdMR3eRMwT3Q+Stdnm/e9sdufo11P0vT4h5lsdPcfjfm7sUZOTN/UtS?= =?us-ascii?Q?9H557Dtfa9xb/kaRreU9HGd9pHrkaOSK89PtsZ8+g5yrk4egAi8nK8y5YKus?= =?us-ascii?Q?xa3Io6VHH5u+1vr8L7l+lExwDbZXE+Is26XCDTmFsWX5V+GbZRa1+UDTBBQ+?= =?us-ascii?Q?lka+4sio9fR1Q644ItV443iN/gWmOlcLkdGIQVi/R+742wibz2HDi/5RE8LM?= =?us-ascii?Q?R9qDCK/sKSh2GIKKW0Q=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06b3bbac-0b12-4b51-fcf9-08da805dbbae X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2022 14:35:29.5311 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: up86fvav4U6rpdtsLCO6svdywz56P5KWAYMstQK0YToGA6BBfQmPlkogD2TB7jTH X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Abner, I just thought that since I'm adding new functions (extending API) I call t= hose functions with Ex suffix. But if you think it is better to have the name without Ex, I can change it = and resubmit. Thank you, Igor -----Original Message----- From: Chang, Abner Sent: Wednesday, August 17, 2022 12:00 AM To: Igor Kulchytskyy ; devel@edk2.groups.io Cc: nickle.wang@hpe.com Subject: [EXTERNAL] RE: [PATCH 3/3] RedfishPkg: The functions for Redfish r= equests do not fully complied with specification **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** [AMD Official Use Only - General] Hi Igor, One question in line. > -----Original Message----- > From: Igor Kulchytskyy > Sent: Tuesday, August 16, 2022 9:25 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; nickle.wang@hpe.com; Igor > Kulchytskyy ; Chang, Abner > Subject: [PATCH 3/3] RedfishPkg: The functions for Redfish requests do > not fully complied with specification > > [CAUTION: External Email] > > There is no function to send POST request with the Content type which > is different from "application/json". > There is no function to send DELETE request with the body. > > Cc: Abner Chang > Cc: Nickle Wang > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/Include/Library/RedfishLib.h | 80 +++++++++ > RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c | 189 > +++++++++++++++++++++ > .../edk2libredfish/include/redfishService.h | 8 + > .../RedfishLib/edk2libredfish/src/service.c | 43 ++++- > 4 files changed, 317 insertions(+), 3 deletions(-) > > diff --git a/RedfishPkg/Include/Library/RedfishLib.h > b/RedfishPkg/Include/Library/RedfishLib.h > index b2488ab..d4b3246 100644 > --- a/RedfishPkg/Include/Library/RedfishLib.h > +++ b/RedfishPkg/Include/Library/RedfishLib.h > @@ -380,6 +380,49 @@ RedfishPatchToPayload ( > OUT REDFISH_RESPONSE *RedResponse > ); > > + > +/** > + Use HTTP POST to create new Redfish resource in the Resource Collectio= n. > + > + The POST request should be submitted to the Resource Collection in > + which the new resource is to belong. The Resource Collection is > + addressed by URI. The Redfish may ignore any service controlled > + properties. The corresponding redfish response will returned, > + including HTTP > StatusCode, Headers and Payload which record any HTTP response messages. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers > + and Payload returned in redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = update. > + @param[in] ContentSize Size of the Content to be send to = Redfish > service > + @param[in] ContentType Type of the Content to be send to = Redfish > service > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX. The > + Redfish resource will be > returned > + in Payload within RedResponse if > + server send it back in the > HTTP > + response message body. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or > RedResponse is NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP > + StatusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is > + NULL, indicates any error > happen. > + 2. If the returned StatusCode is > + not NULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPostToUriEx ( Why not just name this function RedfishPostToUri without "Ex". There is no = PostToUri function currently provided by RedfishLib.c yet. I also see some trailing spaces in this source file by the way. Abner > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize, > + IN CONST CHAR8 *ContentType, > + OUT REDFISH_RESPONSE *RedResponse > + ); > + > + > /** > Use HTTP POST to create a new resource in target payload. > > @@ -451,6 +494,43 @@ RedfishDeleteByUri ( > ); > > /** > + Use HTTP DELETE to remove a resource. > + > + This function uses the RedfishService to remove a Redfish resource > + which is addressed by input Uri (only the relative path is required). > + The corresponding redfish response will returned, including HTTP > + StatusCode, Headers and Payload which record any HTTP response message= s. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers > + and Payload returned in redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = deleted. > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX, the > + Redfish resource has been > removed. > + If there is any message returned > + from server, it will be > returned > + in Payload within RedResponse. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, or RedResponse is > NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP > + StatusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is > + NULL, indicates any error > happen. > + 2. If the returned StatusCode is > + not NULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishDeleteByUriEx ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + OUT REDFISH_RESPONSE *RedResponse > + ); > + > +/** > Dump text in fractions. > > @param[in] String ASCII string to dump. > diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index 9f9d377..c52a518 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > @@ -583,6 +583,104 @@ RedfishPatchToPayload ( > return EFI_SUCCESS; > } > > + > +/** > + Use HTTP POST to create new Redfish resource in the Resource Collectio= n. > + > + The POST request should be submitted to the Resource Collection in > + which the new resource is to belong. The Resource Collection is > + addressed by URI. The Redfish may ignore any service controlled > + properties. The corresponding redfish response will returned, > + including HTTP > StatusCode, Headers and Payload which record any HTTP response messages. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers > + and Payload returned in redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = update. > + @param[in] ContentSize Size of the Content to be send to = Redfish > service > + @param[in] ContentType Type of the Content to be send to = Redfish > service > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX. The > + Redfish resource will be > returned > + in Payload within RedResponse if > + server send it back in the > HTTP > + response message body. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or > RedResponse is NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP > + StatusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is > + NULL, indicates any error > happen. > + 2. If the returned StatusCode is > + not NULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPostToUriEx ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize, > + IN CONST CHAR8 *ContentType, > + OUT REDFISH_RESPONSE *RedResponse > + ) > +{ > + EFI_STATUS Status; > + EDKII_JSON_VALUE JsonValue; > + > + Status =3D EFI_SUCCESS; > + JsonValue =3D NULL; > + > + if ((RedfishService =3D=3D NULL) || (Uri =3D=3D NULL) || (Content =3D= =3D NULL) > + || > (RedResponse =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > + > + JsonValue =3D (EDKII_JSON_VALUE)postUriFromService ( > + RedfishService, > + Uri, > + Content, > + ContentSize, > + ContentType, > + &(RedResponse->StatusCode) > + ); > + > + // > + // 1. If the returned StatusCode is NULL, indicates any error happen. > + // > + if (RedResponse->StatusCode =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + // > + // 2. If the returned StatusCode is not NULL and the value is not > + 2XX, indicates > any error happen. > + // NOTE: If there is any error message returned from server, it wil= l be > returned in > + // Payload within RedResponse. > + // > + if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ > + (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) > + { > + Status =3D EFI_DEVICE_ERROR; > + } > + > +ON_EXIT: > + if (JsonValue !=3D NULL) { > + RedResponse->Payload =3D createRedfishPayload (JsonValue, RedfishSer= vice); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the > +JsonValue > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > + > + > /** > Use HTTP POST to create a new resource in target payload. > > @@ -738,6 +836,97 @@ ON_EXIT: > return Status; > } > > + > +/** > + Use HTTP DELETE to remove a resource. > + > + This function uses the RedfishService to remove a Redfish resource > + which is addressed by input Uri (only the relative path is required). > + The corresponding redfish response will returned, including HTTP > + StatusCode, Headers and Payload which record any HTTP response message= s. > + > + Callers are responsible for freeing the HTTP StatusCode, Headers > + and Payload returned in redfish response data. > + > + @param[in] RedfishService The Service to access the Redfish = resources. > + @param[in] Uri Relative path to address the resou= rce. > + @param[in] Content JSON represented properties to be = deleted. > + @param[out] RedResponse Pointer to the Redfish response da= ta. > + > + @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + NULL and the value is 2XX, the > + Redfish resource has been > removed. > + If there is any message returned > + from server, it will be > returned > + in Payload within RedResponse. > + @retval EFI_INVALID_PARAMETER RedfishService, Uri, or RedResponse is > NULL. > + @retval EFI_DEVICE_ERROR An unexpected system or network error > occurred. Callers can get > + more error info from returned HTTP > + StatusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is > + NULL, indicates any error > happen. > + 2. If the returned StatusCode is > + not NULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishDeleteByUriEx ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + OUT REDFISH_RESPONSE *RedResponse > + ) > +{ > + EFI_STATUS Status; > + EDKII_JSON_VALUE JsonValue; > + > + Status =3D EFI_SUCCESS; > + JsonValue =3D NULL; > + > + if ((RedfishService =3D=3D NULL) || (Content =3D=3D NULL) || (Uri =3D= =3D NULL) > + || > (RedResponse =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); > + > + JsonValue =3D (EDKII_JSON_VALUE)deleteUriFromServiceEx ( > + RedfishService, > + Uri, > + Content, > + &(RedResponse->StatusCode) > + ); > + > + // > + // 1. If the returned StatusCode is NULL, indicates any error happen. > + // > + if (RedResponse->StatusCode =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + // > + // 2. If the returned StatusCode is not NULL and the value is not > + 2XX, indicates > any error happen. > + // NOTE: If there is any error message returned from server, it wil= l be > returned in > + // Payload within RedResponse. > + // > + if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ > + (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) > + { > + Status =3D EFI_DEVICE_ERROR; > + } > + > +ON_EXIT: > + if (JsonValue !=3D NULL) { > + RedResponse->Payload =3D createRedfishPayload (JsonValue, RedfishSer= vice); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the > +JsonValue > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > + > /** > Dump text in fractions. > > diff --git > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishS > ervice.h > b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishS > ervice.h > index 5c13b68..75afadc 100644 > --- > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishS > ervice.h > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redf > +++ is > +++ hService.h > @@ -129,6 +129,14 @@ deleteUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); > > +json_t * > +deleteUriFromServiceEx ( > + redfishService *service, > + const char *uri, > + const char *content, > + EFI_HTTP_STATUS_CODE **StatusCode > + ); > + > redfishPayload * > getRedfishServiceRoot ( > redfishService *service, > diff --git > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > index afa172b..b8bfabe 100644 > --- > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service. > +++ c > @@ -923,10 +923,12 @@ ON_EXIT: > return ret; > } > > + > json_t * > -deleteUriFromService ( > +deleteUriFromServiceEx ( > redfishService *service, > const char *uri, > + const char *content, > EFI_HTTP_STATUS_CODE **StatusCode > ) > { > @@ -937,6 +939,8 @@ deleteUriFromService ( > EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; > EFI_HTTP_MESSAGE *RequestMsg =3D NULL; > EFI_HTTP_MESSAGE ResponseMsg; > + CHAR8 ContentLengthStr[80]; > + size_t contentLength; > > ret =3D NULL; > > @@ -956,7 +960,7 @@ deleteUriFromService ( > // > // Step 1: Create HTTP request message with 4 headers: > // > - HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || > service- > >basicAuthStr) ? 5 : 4); > + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || > + service->basicAuthStr) ? 8 : 7); > if (HttpIoHeader =3D=3D NULL) { > ret =3D NULL; > goto ON_EXIT; > @@ -979,6 +983,23 @@ deleteUriFromService ( > Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); > ASSERT_EFI_ERROR (Status); > > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", > + "application/json"); ASSERT_EFI_ERROR (Status); > + > + if(content !=3D NULL){ > + contentLength =3D strlen (content); > + AsciiSPrint ( > + ContentLengthStr, > + sizeof (ContentLengthStr), > + "%lu", > + (UINT64)contentLength > + ); > + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", > ContentLengthStr); > + ASSERT_EFI_ERROR (Status); > + Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); > + ASSERT_EFI_ERROR (Status); > + } > + > // > // Step 2: build the rest of HTTP request info. > // > @@ -1003,7 +1024,12 @@ deleteUriFromService ( > RequestMsg->Data.Request =3D RequestData; > RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; > RequestMsg->Headers =3D HttpIoHeader->Headers; > - > + > + if(content !=3D NULL){ > + RequestMsg->BodyLength =3D contentLength; > + RequestMsg->Body =3D (VOID *)content; > + } > + > ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); > > // > @@ -1057,6 +1083,17 @@ ON_EXIT: > return ret; > } > > +json_t * > +deleteUriFromService ( > + redfishService *service, > + const char *uri, > + EFI_HTTP_STATUS_CODE **StatusCode > + ) > +{ > + return deleteUriFromServiceEx(service, uri, NULL, StatusCode); } > + > + > redfishPayload * > getRedfishServiceRoot ( > redfishService *service, > -- > 2.6.1.windows.1 > -The information contained in this message may be confidential and > proprietary to American Megatrends (AMI). This communication is > intended to be read only by the individual or entity to whom it is > addressed or by their designee. If the reader of this message is not > the intended recipient, you are on notice that any distribution of > this message, in any form, is strictly prohibited. Please promptly > notify the sender by reply e-mail or by telephone at 770-246-8600, and th= en delete or destroy all copies of the transmission. -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= .