From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.72]) by mx.groups.io with SMTP id smtpd.web11.589.1660895529781564997 for ; Fri, 19 Aug 2022 00:52:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=WVrK/wIZ; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.92.72, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JzipN+9CJa0pk0Gi9yRZPM1TvIaU/imxfHxFkwr6iKloOJ+ynZ2OtJBhVD/Nkqej250IdpjFlMXe6tv3djOCnPCYhQW2YNZzNSc/xzxZJJTDe1iCi5aVWuGr7YMt1zuY5rrX+b0VN1wUEwwP+GbGKPIJGMTw3qt+jmBbxx3B54xStuXTju4OF8ntAHJCi+cku2VoKGRThYCvO3f4dFosJKdA+1uHHkWULMj1hRhaWNx9Q2BvHYczl+XcNg/yuNH34PSSBvujaae9c54/SK15H8uPqlE5kcvHwzcD17yTkDva4361k4zl3IzhVwDEFRqJ8L9gyaft5OXOMTk/uBdX8A== 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=hMaqozq1QdECwFyaIHxt89ndd5inlNiN6+an8isNwj0=; b=cqHN19BZcWIkO11O5g+zxWnWy9DJdITjX8gMVtfpPPe9DTi5v5Iy4j46QeNzr88IX5ucuAr5Yf4dY6mAFhp9qT5n/b23+YZMu81RmL4bsEORIbVxV2UrguF+7AWtIeW5CP939DM01IxBtYxXhAVHbKNTRM6nKoMuxtij05xTJzMSGQawQI63/KmqtaFl4gv0H6H8sIcoo8sHGddlpHMCqTeN43wzMfg7p2jCBqlXHmpjVT9zJqURbZO2iWtJ854z+SAgO6J4Oml/HOiLJZU31SAx3VJ47oZ6Xv0832ElGjm6fo6xRG55VWRZvaI8dZEaQQoz89Vpm+QlmLxDTS5+mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hMaqozq1QdECwFyaIHxt89ndd5inlNiN6+an8isNwj0=; b=WVrK/wIZn/cR5dZmT62TY0/5fIlpO5akFInoeMW3cdrK9sHuNhBXUEC+a2s536vXg57GaRo3Oxd2Mq+SxSAi8vuYZ7NkB/c4v/fAlLoqAYID/K0JkENxqq6rcsq5qd1xA5ZsP2oi5Ui3jUsNJtPtOrrYtM5u794X61DMK/iSCeA= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by BL1PR12MB5351.namprd12.prod.outlook.com (2603:10b6:208:317::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Fri, 19 Aug 2022 07:52:07 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e850:8264:41be:cb1f]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e850:8264:41be:cb1f%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 07:52:07 +0000 From: "Chang, Abner" To: Igor Kulchytskyy , "devel@edk2.groups.io" CC: "nickle.wang@hpe.com" Subject: Re: [PATCH V4 3/3] RedfishPkg: Redfish functions for REST requests are not fully spec complied Thread-Topic: [PATCH V4 3/3] RedfishPkg: Redfish functions for REST requests are not fully spec complied Thread-Index: AQHYszqD8Z4AxLEDXkCisiWzK4C+ma212pYQ Date: Fri, 19 Aug 2022 07:52:07 +0000 Message-ID: References: <1660851683-3680-1-git-send-email-igork@ami.com> In-Reply-To: <1660851683-3680-1-git-send-email-igork@ami.com> Accept-Language: zh-CN, 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-19T07:52:04Z; 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=f5b48a32-183f-4a81-a894-d0680ce59e3e; 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=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b5c05ff3-6c40-49f0-dc1e-08da81b7b6c7 x-ms-traffictypediagnostic: BL1PR12MB5351:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zS6g8OkTdudszFrTzucW2I5uU0uzDCvgvEWePVvHfJCMTTYE1RDYvq28LBSuf0BS2WmIIEFP2hBYFJLv5S3tbU0dcRKQoQlDrACRaiBM+LIZEaIHp+wznT0EPgLtiGGu2w3TdJ4Tu46Si/Rxi2ztn7cWrbVdLCMflWT3xkZ0/sS+XZnkMIyrBCCk6e5oD8CFe1vK4+AnloqxoqUdYeOfWCyQqHoa84zFqpWrqRbtiQXdyoHX5FChh0jubgp6RZa8NO8N+RWorYwxg5tUgphIhGEeqDVJ6ro671cUDucJlFEc+ynWMnwGHUhTvrnLLxR7+3FiJ4EfX2B/6QcpHr8jpgYp90db03W1s1DEQRgNXRBMN6TpM6G4VmKsXPA3opKas16g4MdnzyIjV/oYjDc2sfEN4Vub6igk/psvTmae62XWfsVFJzquvpsX1FjJhjHNhg0BynpsDFbx4qkgePEBHmw61MHeaOxDjAwzaRz8JKXAj0PK1npjK/TnuW3fP0TXkdaSGGi4MJkei7KQQ2a4RAw7w4w/xR5Y3FpEhfj+ZYTIdcCY40uGdXVQ9DQjwD12VsDnQb+w2+ceE4L6ft9Lxr94JIHMjRtGiR4qACOwwanDF6JQXPT7gCPDHfYDsrxL+0oy+4NlZXVe5ypqBb5MMdgqR0o4Y0RZGbCpNw45ayC7p7g3gJYJzfyuYDAedjMZA6xp0jD99NxBWL4kGE5LioHJ38GLVjLy/E+uW5qaIuhhQfRRXgx0yCIa7wsXER4FeOgUQJyvgm1eXoZRifPUYA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(136003)(346002)(39860400002)(396003)(376002)(110136005)(71200400001)(66946007)(6506007)(9686003)(5660300002)(66476007)(316002)(52536014)(38100700002)(64756008)(86362001)(4326008)(66556008)(8936002)(66446008)(30864003)(53546011)(38070700005)(41300700001)(7696005)(8676002)(186003)(2906002)(26005)(55016003)(478600001)(122000001)(76116006)(40140700001)(33656002)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?1DGa4mTb+Fqv4Qy5WjBYJcveaTVwUy+nNdD3VOKi0914t/86+lxkuG6krZIv?= =?us-ascii?Q?pLYMb9jsJrBSKVr7jfzG0QCU9TBCIe4VTCJ7eaODnItvYI5faVav3ceX94Vh?= =?us-ascii?Q?T1J7Tf0R6DSF6x95K1ON8uWRHxnOtEJ4E7MtO00Pj6/IhFrnnL2rMhxaSuiv?= =?us-ascii?Q?iTecvYbcPdZEu6vnn3Dy3lklq+xoCDP3DSEiObUsd/8CQpnB8rAwEKJWNX9W?= =?us-ascii?Q?hIA1VqPiXYQcJdXZlB6pPfho1I29iEycFk4yL4ck8u3Q8LNB7AWuNAgK0OLf?= =?us-ascii?Q?6PlgDy1k6JvEnGaWdgddLJsQZvl5dmK9AUfT0Bn6etqvwmDvB2/z3z158dh8?= =?us-ascii?Q?Zp3zOKanirnmNh2/WW7FQa7+k76rZnnpfysmp351zCLv9qDzmbDs8PBHpPzF?= =?us-ascii?Q?PnJq28KbhNnUYo9jKtl+xdg2OaIXyDMe5CTBbEMl6wZl5fNmkey8fUBjanTT?= =?us-ascii?Q?ruebRTHOe/pnCjnRmN86atoJIINsL/xCfXoOlzsyd5LChhcjyN3QwEcAzhxn?= =?us-ascii?Q?7ADr7YzBpMJbMJ684qqf5ZI2exE3Xuv62vUw9HRuDLYayUi5IZrf3MByE0OP?= =?us-ascii?Q?0RAW9cwYZ0Py/TDEBwYrolgxduE5uPVXnEcTbhIiZIUkqqLBZUW/zDLPLE3K?= =?us-ascii?Q?FyysIiv0zuYQT8FhdXkZP+I42se+CagrK34Iu5Tt24HBvrKugk5kEQRY45Od?= =?us-ascii?Q?37xfj3ShB8Qf2kBzSZ8XtGPfwZ3ki8UqmCo7vzsJV4P1+I379bMTQTk5CElw?= =?us-ascii?Q?VD4KDqkpZOiTG2QliK/hjqllF97K4DTWAb60KwhUQDo7ZIMxoO7goDqKNDAe?= =?us-ascii?Q?zDwfBDwG3T5uivkDcCwzqylDQj+XRB8lQNBnGFNmcVk1ytownJzCDWgU11cS?= =?us-ascii?Q?iH2C/h/yJXmcUZHZ41T+X4xPAbas8glAByLwkOc7r7kYOmFFaY5XogRhUM5G?= =?us-ascii?Q?4Gw7+Jfx0XAujvNH3+IaVaEuRGSXqaigwrxDdUnQAut0pOPrLbC8dVARP6qk?= =?us-ascii?Q?IdsVZHhT8SIN6mU+zw1qrZ6eeSZxpVR0w21pWL1ZDyvV3jtkqRdaHFjeUKT+?= =?us-ascii?Q?MYKvGqtK95YewY7Y8Noh+18o59Mqjl6mLPDCe/M+DU+QUGYNxRfMBPV2+Fpx?= =?us-ascii?Q?CGiUpYvvk5FOnPyHSl7wb9lsEnG7OSVoxK/Xvd8jTJqSQRoU9NMvjyv99sva?= =?us-ascii?Q?brEMDbabsR58/fUE+Da8hzzcYLLQlNuP/CeoHqSYtQ4doiun+ftlfEJ64hYs?= =?us-ascii?Q?SvnjSOeof63FJkypy/u8NbA5TPpDfSaMLJtOUNFDEjWsekpFPs5XBfeQJ8NS?= =?us-ascii?Q?OFYYCTudQOQ7rQpH4fg+wKU4Tce/WWkYnvINJHPiO70ono01vGTBtKMIIO/w?= =?us-ascii?Q?vRZI5b3b06b9pEMrqPax7uiEC8DOIt6tq3HUVr4l/bf9Z1QLJvi+7I7eb2B9?= =?us-ascii?Q?XfQPnuNybSbF4xFWTpi65l0gRGwsI2zRBnkH7Cee3WKLpvrvWJSDYfD1AP+0?= =?us-ascii?Q?nz9hUBTv6uMMxQCwj1cUiE/bFDhDasK4JqUVr2tNeMt1CXJWuU4Srd+PmGIM?= =?us-ascii?Q?wBQ2OtDwsVojC2/xhKG4l9KuATFnWP7X6LPtkRLb?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5c05ff3-6c40-49f0-dc1e-08da81b7b6c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2022 07:52:07.1427 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GsnxvBfXUsvy/rlivBm4dSp9i0YKlTbapDn2jEPFcbmy1gVEYtwlBWACkz+QE1XPaQRdZ6Dr1Y+oDLDVmwTTxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5351 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang Thanks! > -----Original Message----- > From: Igor Kulchytskyy > Sent: Friday, August 19, 2022 3:41 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; nickle.wang@hpe.com; Igor > Kulchytskyy ; Chang, Abner > Subject: [PATCH V4 3/3] RedfishPkg: Redfish functions for REST requests a= re > not fully spec complied >=20 > [CAUTION: External Email] >=20 > There is no function to send POST request with the ContentType different > from "application\json". > There is no function to send DELETE request with the body. >=20 > Cc: Abner Chang > Cc: Nickle Wang > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/Include/Library/RedfishLib.h = | 80 +++++++++ > RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c = | 189 > ++++++++++++++++++++ >=20 > RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishServic= e. > h | 8 + > RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c = | 41 > ++++- > 4 files changed, 316 insertions(+), 2 deletions(-) >=20 > diff --git a/RedfishPkg/Include/Library/RedfishLib.h > b/RedfishPkg/Include/Library/RedfishLib.h > index b2488ab..ce39ce3 100644 > --- a/RedfishPkg/Include/Library/RedfishLib.h > +++ b/RedfishPkg/Include/Library/RedfishLib.h > @@ -380,6 +380,49 @@ RedfishPatchToPayload ( > OUT REDFISH_RESPONSE *RedResponse > ); >=20 > + > +/** > + 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, includin= g > 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 serve= r 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 Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPostToUri ( > + 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. >=20 > @@ -451,6 +494,43 @@ RedfishDeleteByUri ( > ); >=20 > /** > + 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 > 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 = 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 Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL 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. >=20 > @param[in] String ASCII string to dump. > diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index 9f9d377..6c0f426 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > @@ -583,6 +583,104 @@ RedfishPatchToPayload ( > return EFI_SUCCESS; > } >=20 > + > +/** > + 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, includin= g > 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 serve= r 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 Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL and the value is > not 2XX, > + indicates any error happen. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishPostToUri ( > + 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, > RedfishService); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the Json= Value > 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. >=20 > @@ -738,6 +836,97 @@ ON_EXIT: > return Status; > } >=20 > + > +/** > + 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 > 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 = 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 Sta= tusCode, Headers > and Payload > + within RedResponse: > + 1. If the returned StatusCode is NULL,= indicates any error > happen. > + 2. If the returned StatusCode is not N= ULL 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, > RedfishService); > + if (RedResponse->Payload =3D=3D NULL) { > + // > + // Ignore the error when create RedfishPayload, just free the Json= Value > since it's not what > + // we care about if the returned StatusCode is 2XX. > + // > + JsonValueFree (JsonValue); > + } > + } > + > + return Status; > +} > + > /** > Dump text in fractions. >=20 > diff --git > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishServ= ic > e.h > b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishServ= ic > e.h > index 5c13b68..75afadc 100644 > --- > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishServ= ic > e.h > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfis > +++ hService.h > @@ -129,6 +129,14 @@ deleteUriFromService ( > EFI_HTTP_STATUS_CODE **StatusCode > ); >=20 > +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/serv= ice.c > b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c > index afa172b..086e04a 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; > } >=20 > + > 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; >=20 > ret =3D NULL; >=20 > @@ -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); >=20 > + 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. > // > @@ -1004,6 +1025,11 @@ deleteUriFromService ( > RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; > RequestMsg->Headers =3D HttpIoHeader->Headers; >=20 > + if(content !=3D NULL){ > + RequestMsg->BodyLength =3D contentLength; > + RequestMsg->Body =3D (VOID *)content; > + } > + > ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); >=20 > // > @@ -1057,6 +1083,17 @@ ON_EXIT: > return ret; > } >=20 > +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, yo= u 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 then delete or destroy all copies of the > transmission.