From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D0F669411B6 for ; Thu, 26 Oct 2023 06:04:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+NUNa6HBolvxLmRGn0g7miDdEt2FeIVQePI22+9KUTU=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1698300291; v=1; b=qI0ffAERENBeemaX1BGJlVFwLy4nex+Es+80iNidfPwdblRXYNmFCrKQbsR9so8EAXv1fUZp kawZtK+o7BDHt5pKVGIb4mL5nSfrNPW0yNHCjXzkij+3DXmBwCdttNoyQyssaom+hvz6TZrumW5 ZpfJd9u9GqJMx15UYBhmi6ng= X-Received: by 127.0.0.2 with SMTP id hltsYY7687511xdqseK5YAYH; Wed, 25 Oct 2023 23:04:51 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.68]) by mx.groups.io with SMTP id smtpd.web11.64291.1698300290617176165 for ; Wed, 25 Oct 2023 23:04:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9zGghWZ+SJ5B+zLXoI8msg1RItr1M+8PYVNwnnKQMoRehRY6ofX6HJDhnvMZlO2Q3KXlml6sL3Siyxw2ozpepE+Xyl5NIKwX+d7Jzma35DJed9k4OjzxgMccFKH/6oX8u9svgDzxrsNiQ6LYUnxPksGzYHFVo9ijOu60WukobSQ//H7GEEAjrtF8GcQ3J1I/8TGkZVCFLEJXL+JQitPfS3Hj7YYCLBiFH5ipDumRtOeqXuPvZW88zAKINAacTeiljEHtT5Zb4MQ3TR/jVLhx0XOJlmA6TP+muMLqdEGmEcRdNc0+JByARuuBha3WQIfdmc2xFx2RVg8TWo6Td0rCg== 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=fOphl3s2Dsn88FJ2pk/mpLajA+QoWDwopuim2eTrdyw=; b=WR3jGdru+N0+dHqcQOKHE+x/GGpzmwQS8AQk+t3MH9h+/oK4aLQxokwHGVcPRs9jZ7FAISaxw/CQOwiZPrhAbPIMNm1fenhV2ScrBdVEeeX5JNktUJpkWbCDerqjSGxK1ZGcEWEE/xZV3WbnybGGbNnFNWT91Jd26kFSK2Bc5eDL3ljhwddfPfsrY9HgzqdkW+0VgmPsTF8nBTs1z550UmsXwiyzjWtPM+sm/4L7Yj6BWgB8W6jeXQwnIT8gbcb/vLPV12Bqw2c3Sa/83HgmnDaKp6KdC02Q+CkcHjjNc3XUIgwIpLUdGmxqnmppoJdpGGf9fBcBNlxJDC060Y4hfA== 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 X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by PH7PR12MB5653.namprd12.prod.outlook.com (2603:10b6:510:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Thu, 26 Oct 2023 06:04:47 +0000 X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e670:e45f:fa32:2420]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::e670:e45f:fa32:2420%6]) with mapi id 15.20.6933.019; Thu, 26 Oct 2023 06:04:47 +0000 From: "Chang, Abner via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [edk2-devel] [PATCH 1/3] RedfishPkg/RedfishLib: introduce new interfaces. Thread-Topic: [PATCH 1/3] RedfishPkg/RedfishLib: introduce new interfaces. Thread-Index: AQHaBlWTDRe0Q6SKH0WmWX26zactL7Bbl+Tg Date: Thu, 26 Oct 2023 06:04:47 +0000 Message-ID: References: <20231024083857.16006-1-nicklew@nvidia.com> In-Reply-To: <20231024083857.16006-1-nicklew@nvidia.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=58edf4c0-c1ce-47b7-9416-a995b68466d7;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;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_SetDate=2023-10-26T06:04:29Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|PH7PR12MB5653:EE_ x-ms-office365-filtering-correlation-id: bfb61129-7365-4d86-2ecb-08dbd5e9753a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: xyiXK9iBItrdmR4L7Uk85N2mQLqEYXcEGd32GJJH8eY//UDvWnFPupLfu8zBiDfDMQTzAEYyE4aYnBnixMieAY9lT0PPeuiOS4OIh1lhJOUtnOx6nua/lMkGsfSSSK3lZDM/ZFNMz+webfqgA782q87j9l010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?us-ascii?Q?wAESOuzdbLF0zprxveVT9gpQNc6S5yNQrMx7Qz4waWc3EZgNbQbBFXogyD9D?= =?us-ascii?Q?stgMCKmJY44MDlLS1YEfbtAcahmrhsqw/Lu5bK1kqUjdVBRrR0cR9V6nMJH1?= =?us-ascii?Q?l1OOLK7eYr8tc545y3N90hx8FBfw/K6aw4VEcNq/zbLGOEX1Fb1vgw7Ss+OX?= =?us-ascii?Q?VcCAT/eFIGPdElhMgMOOa/8Ozea1IitQm8bV5RdIHEENCacwX5VhxaqqZmEF?= =?us-ascii?Q?PzEMTulf0E1Si9DTgWwam1V14IkIx9c6e5HcnbbG?= 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: bfb61129-7365-4d86-2ecb-08dbd5e9753a X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2023 06:04:47.3885 (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: Szb7oAkzcAsjpU/J2SLsWlnxmCXr0nno2KWn+UIac2Qj9XBEYPw39coxBcNjSX1tDBTc1fGpp78laMgSqlJ9hA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5653 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: fZW4VjhZDLftMljKa5qfjtYkx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=qI0ffAER; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Tuesday, October 24, 2023 4:39 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > ; Nick Ramirez > Subject: [PATCH 1/3] RedfishPkg/RedfishLib: introduce new interfaces. > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > Add two new interface: RedfishServiceInPayload() and RedfishPutToUri() > for Redfish HTTP protocol implementation. Fix several typos and add > missing JsonLib in INF file. > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > .../PrivateLibrary/RedfishLib/RedfishLib.inf | 2 + > RedfishPkg/Include/Library/RedfishLib.h | 95 +++++++++-- > .../PrivateLibrary/RedfishLib/RedfishLib.c | 153 ++++++++++++++++-- > .../PrivateLibrary/RedfishLib/RedfishMisc.c | 13 +- > 4 files changed, 226 insertions(+), 37 deletions(-) > > diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > index 128d511df7c9..124ecb1e3aae 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > @@ -3,6 +3,7 @@ > # > # Copyright (c) 2019, Intel Corporation. All rights reserved.
> # (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -42,6 +43,7 @@ > BaseLib > BaseMemoryLib > DebugLib > + JsonLib > HttpLib > MemoryAllocationLib > NetLib > diff --git a/RedfishPkg/Include/Library/RedfishLib.h > b/RedfishPkg/Include/Library/RedfishLib.h > index 28c2b290e613..8309a67c769f 100644 > --- a/RedfishPkg/Include/Library/RedfishLib.h > +++ b/RedfishPkg/Include/Library/RedfishLib.h > @@ -61,6 +61,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -183,6 +184,23 @@ RedfishJsonInPayload ( > IN REDFISH_PAYLOAD Payload > ); > > +/** > + This function returns the Redfish service of a REDFISH_PAYLOAD. > + > + Caller doesn't need to free the returned JSON value because it will be > released > + in corresponding RedfishCleanupService() function. > + > + @param[in] Payload A REDFISH_PAYLOAD instance. > + > + @return Redfish service of the payload. > + > +**/ > +REDFISH_SERVICE > +EFIAPI > +RedfishServiceInPayload ( > + IN REDFISH_PAYLOAD Payload > + ); > + > /** > Fill the input RedPath string with system UUID from SMBIOS table or us= e the > customized > ID if FromSmbios =3D=3D FALSE. > @@ -222,7 +240,7 @@ RedfishBuildPathWithSystemUuid ( > from the root node. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -252,7 +270,7 @@ RedfishGetByService ( > @param[in] URI String to address a resource. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -282,7 +300,7 @@ RedfishGetByUri ( > @param[in] RedPath Relative RedPath string to address a r= esource > inside Payload. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful: > + @retval EFI_SUCCESS The operation is successful: > 1. The HTTP StatusCode is NULL and the= returned Payload in > RedResponse is not NULL, indicates the= Redfish resource has > been parsed from the input payload dir= ectly. > @@ -323,7 +341,7 @@ RedfishGetByPayload ( > @param[in] Content JSON represented properties to be = update. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -357,10 +375,10 @@ RedfishPatchToUri ( > redfish response data. > > @param[in] Target The target payload to be updated. > - @param[in] Payload Palyoad with properties to be changed. > + @param[in] Payload Payload with properties to be changed. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -398,7 +416,7 @@ RedfishPatchToPayload ( > @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 > + @retval EFI_SUCCESS The operation 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. > @@ -416,8 +434,8 @@ RedfishPostToUri ( > IN REDFISH_SERVICE RedfishService, > IN CONST CHAR8 *Uri, > IN CONST CHAR8 *Content, > - IN UINTN ContentSize, > - IN CONST CHAR8 *ContentType, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > OUT REDFISH_RESPONSE *RedResponse > ); > > @@ -436,7 +454,7 @@ RedfishPostToUri ( > @param[in] Payload The new resource to be created. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -471,7 +489,7 @@ RedfishPostToPayload ( > @param[in] Uri Relative path to address the resou= rce. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -507,7 +525,7 @@ RedfishDeleteByUri ( > @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 > + @retval EFI_SUCCESS The operation 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. > @@ -528,6 +546,49 @@ RedfishDeleteByUriEx ( > OUT REDFISH_RESPONSE *RedResponse > ); > > +/** > + Use HTTP PUT to create new Redfish resource in the Resource Collection= . > + > + This function uses the RedfishService to put a Redfish resource addres= sed by > + Uri (only the relative path is required). Changes to one or more prope= rties > within > + the target resource are represented in the input Content, properties n= ot > specified > + in Content won't be changed by this request. 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 operation 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 > +RedfishPutToUri ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > + OUT REDFISH_RESPONSE *RedResponse > + ); > + > /** > Dump text in fractions. > > @@ -582,7 +643,7 @@ RedfishFreeResponse ( > Check if the "@odata.type" in Payload is valid or not. > > @param[in] Payload The Redfish payload to be checked= . > - @param[in] OdataTypeName OdataType will be retrived from > mapping list. > + @param[in] OdataTypeName OdataType will be retrieved from > mapping list. > @param[in] OdataTypeMappingList The list of OdataType. > @param[in] OdataTypeMappingListSize The number of mapping list > > @@ -616,7 +677,7 @@ RedfishIsPayloadCollection ( > @param[in] Payload The Redfish collection payload > @param[in] CollectionSize Size of this collection > > - @return EFI_SUCCESS Coolection size is returned in Collec= tionSize > + @return EFI_SUCCESS Collection size is returned in Collec= tionSize > @return EFI_INVALID_PARAMETER The payload is not a collection. > **/ > EFI_STATUS > @@ -674,18 +735,18 @@ RedfishGetServiceVersion ( > /** > This function returns the string of Redfish service version. > > - @param[in] ServiceVerisonStr The string of Redfish service version. > + @param[in] ServiceVersionStr The string of Redfish service version. > @param[in] Url The URL to build Redpath with ID. > Start with "/", for example "/Registrie= s" > @param[in] Id ID string > - @param[out] Redpath Pointer to retrive Redpath, caller has = to free > + @param[out] Redpath Pointer to retrieved Redpath, caller ha= s to free > the memory allocated for this string. > @return EFI_STATUS > > **/ > EFI_STATUS > RedfishBuildRedpathUseId ( > - IN CHAR8 *ServiceVerisonStr, > + IN CHAR8 *ServiceVersionStr, > IN CHAR8 *Url, > IN CHAR8 *Id, > OUT CHAR8 **Redpath > diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > index cca0ea774893..f4045044829a 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c > @@ -4,6 +4,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -167,6 +168,30 @@ RedfishJsonInPayload ( > return ((redfishPayload *)Payload)->json; > } > > +/** > + This function returns the Redfish service of a REDFISH_PAYLOAD. > + > + Caller doesn't need to free the returned JSON value because it will be > released > + in corresponding RedfishCleanupService() function. > + > + @param[in] Payload A REDFISH_PAYLOAD instance. > + > + @return Redfish service of the payload. > + > +**/ > +REDFISH_SERVICE > +EFIAPI > +RedfishServiceInPayload ( > + IN REDFISH_PAYLOAD Payload > + ) > +{ > + if (Payload =3D=3D NULL) { > + return NULL; > + } > + > + return ((redfishPayload *)Payload)->service; > +} > + > /** > Fill the input RedPath string with system UUID from SMBIOS table or us= e the > customized > ID if FromSmbios =3D=3D FALSE. > @@ -244,7 +269,7 @@ RedfishBuildPathWithSystemUuid ( > from the root node. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -304,7 +329,7 @@ RedfishGetByService ( > @param[in] Uri String to address a resource. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation is successful, indicates= the HTTP > StatusCode is not > NULL and the value is 2XX. The corresp= onding redfish > resource has > been returned in Payload within RedRes= ponse. > @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or > RedResponse is NULL. > @@ -367,7 +392,7 @@ RedfishGetByUri ( > @param[in] RedPath Relative RedPath string to address a r= esource > inside Payload. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful: > + @retval EFI_SUCCESS The operation is successful: > 1. The HTTP StatusCode is NULL and the= returned Payload in > RedResponse is not NULL, indicates the= Redfish resource has > been parsed from the input payload dir= ectly. > @@ -440,7 +465,7 @@ RedfishGetByPayload ( > @param[in] Content JSON represented properties to be = update. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -527,10 +552,10 @@ ON_EXIT: > redfish response data. > > @param[in] Target The target payload to be updated. > - @param[in] Payload Palyoad with properties to be changed. > + @param[in] Payload Payload with properties to be changed. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -601,7 +626,7 @@ RedfishPatchToPayload ( > @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 > + @retval EFI_SUCCESS The operation 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. > @@ -619,8 +644,8 @@ RedfishPostToUri ( > IN REDFISH_SERVICE RedfishService, > IN CONST CHAR8 *Uri, > IN CONST CHAR8 *Content, > - IN UINTN ContentSize, > - IN CONST CHAR8 *ContentType, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > OUT REDFISH_RESPONSE *RedResponse > ) > { > @@ -694,7 +719,7 @@ ON_EXIT: > @param[in] Payload The new resource to be created. > @param[out] RedResponse Pointer to the Redfish response data. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -762,7 +787,7 @@ RedfishPostToPayload ( > @param[in] Uri Relative path to address the resou= rce. > @param[out] RedResponse Pointer to the Redfish response da= ta. > > - @retval EFI_SUCCESS The opeartion is successful, indicates= the HTTP > StatusCode is not > + @retval EFI_SUCCESS The operation 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. > @@ -850,7 +875,7 @@ ON_EXIT: > @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 > + @retval EFI_SUCCESS The operation 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. > @@ -1060,7 +1085,7 @@ RedfishFreeResponse ( > Check if the "@odata.type" in Payload is valid or not. > > @param[in] Payload The Redfish payload to be checked= . > - @param[in] OdataTypeName OdataType will be retrived from > mapping list. > + @param[in] OdataTypeName OdataType will be retrieved from > mapping list. > @param[in] OdataTypeMappingList The list of OdataType. > @param[in] OdataTypeMappingListSize The number of mapping list > > @@ -1127,7 +1152,7 @@ RedfishIsPayloadCollection ( > @param[in] Payload The Redfish collection payload > @param[in] CollectionSize Size of this collection > > - @return EFI_SUCCESS Coolection size is returned in Collec= tionSize > + @return EFI_SUCCESS Collection size is returned in Collec= tionSize > @return EFI_INVALID_PARAMETER The payload is not a collection. > **/ > EFI_STATUS > @@ -1217,3 +1242,103 @@ RedfishCheckIfRedpathExist ( > > return EFI_SUCCESS; > } > + > +/** > + Use HTTP PUT to create new Redfish resource in the Resource Collection= . > + > + This function uses the RedfishService to put a Redfish resource addres= sed by > + Uri (only the relative path is required). Changes to one or more prope= rties > within > + the target resource are represented in the input Content, properties n= ot > specified > + in Content won't be changed by this request. 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 operation 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 > +RedfishPutToUri ( > + IN REDFISH_SERVICE RedfishService, > + IN CONST CHAR8 *Uri, > + IN CONST CHAR8 *Content, > + IN UINTN ContentSize OPTIONAL, > + IN CONST CHAR8 *ContentType OPTIONAL, > + 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)putUriFromServiceEx ( > + RedfishService, > + Uri, > + Content, > + ContentSize, > + ContentType, > + &(RedResponse->Headers), > + &(RedResponse->HeaderCount), > + &(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; > +} > diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > index 0eb23196d2c2..b6e9a111785a 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c > @@ -3,6 +3,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -168,18 +169,18 @@ RedfishGetAuthInfo ( > /** > This function returns the string of Redfish service version. > > - @param[in] ServiceVerisonStr The string of Redfish service version. > + @param[in] ServiceVersionStr The string of Redfish service version. > @param[in] Url The URL to build Redpath with ID. > Start with "/", for example "/Registrie= s" > @param[in] Id ID string > - @param[out] Redpath Pointer to retrive Redpath, caller has = to free > + @param[out] Redpath Pointer to retrieved Redpath, caller ha= s to free > the memory allocated for this string. > @return EFI_STATUS > > **/ > EFI_STATUS > RedfishBuildRedpathUseId ( > - IN CHAR8 *ServiceVerisonStr, > + IN CHAR8 *ServiceVersionStr, > IN CHAR8 *Url, > IN CHAR8 *Id, > OUT CHAR8 **Redpath > @@ -187,12 +188,12 @@ RedfishBuildRedpathUseId ( > { > UINTN RedpathSize; > > - if ((Redpath =3D=3D NULL) || (ServiceVerisonStr =3D=3D NULL) || (Url = =3D=3D NULL) || (Id > =3D=3D NULL)) { > + if ((Redpath =3D=3D NULL) || (ServiceVersionStr =3D=3D NULL) || (Url = =3D=3D NULL) || (Id > =3D=3D NULL)) { > return EFI_INVALID_PARAMETER; > } > > RedpathSize =3D AsciiStrLen ("/") + > - AsciiStrLen (ServiceVerisonStr) + > + AsciiStrLen (ServiceVersionStr) + > AsciiStrLen (Url) + > AsciiStrLen ("[Id=3D]") + > AsciiStrLen (Id) + 1; > @@ -201,6 +202,6 @@ RedfishBuildRedpathUseId ( > return EFI_OUT_OF_RESOURCES; > } > > - AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=3D%a]", ServiceVerisonSt= r, Url, > Id); > + AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=3D%a]", ServiceVersionSt= r, Url, > Id); > return EFI_SUCCESS; > } > -- > 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110074): https://edk2.groups.io/g/devel/message/110074 Mute This Topic: https://groups.io/mt/102154011/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-