]> git.proxmox.com Git - mirror_edk2.git/commitdiff
RedfishPkg: Redfish modules may need to use the functions which are private
authorAbner Chang <abner.chang@amd.com>
Wed, 17 Aug 2022 03:28:25 +0000 (11:28 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 23 Aug 2022 03:13:11 +0000 (03:13 +0000)
Definitions of the required functions to send requests to BMC
are in the PrivateInclude folder. So they cannot be used by
the other Redfish packages.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
RedfishPkg/Include/Library/RedfishLib.h [new file with mode: 0644]
RedfishPkg/PrivateInclude/Library/RedfishLib.h [deleted file]
RedfishPkg/RedfishPkg.dec

diff --git a/RedfishPkg/Include/Library/RedfishLib.h b/RedfishPkg/Include/Library/RedfishLib.h
new file mode 100644 (file)
index 0000000..b2488ab
--- /dev/null
@@ -0,0 +1,616 @@
+/** @file\r
+  This library provides a set of utility APIs that allow to create/read/update/delete\r
+  (CRUD) Redfish resources and provide basic query abilities by using [URI/RedPath]\r
+  (https://github.com/DMTF/libredfish).\r
+\r
+  The query language is based on XPath (https://www.w3.org/TR/1999/REC-xpath-19991116/).\r
+  This library and query language essentially treat the entire Redfish Service like it\r
+  was a single JSON document. In other words whenever it encounters an odata.id in JSON\r
+  document, it will retrieve the new JSON document (if needed). We name the path as\r
+  RedPath:\r
+\r
+  Expression       Description\r
+\r
+  nodename         Selects the JSON entity with the name "nodename".\r
+                   If the value of nodename is an object with "@odata.id",\r
+                   it will continue get the value from "@odata.id".\r
+\r
+  /                Selects from the root node\r
+\r
+  [index]           Selects the index number JSON entity from an array or\r
+                   object. If the JSON entity is one collection (has\r
+                   Members & Members@odata.count), means to get the index\r
+                   member in "Members". Index number >=1, 1 means to return\r
+                   the first instance.\r
+\r
+  [XXX]            Operation on JSON entity.\r
+                   If the JSON entity is one collection (has Members &\r
+                   Members@odata.count), means to get all elements in\r
+                   "Members". If the JSON entity is one array, means to\r
+                   get all elements in array. Others will match the nodename\r
+                   directly (e.g. JSON_OBJECT, JSON_STRING, JSON_TRUE,\r
+                   JSON_FALSE, JSON_INTEGER).\r
+\r
+  [nodename]       Selects all the elements from an JSON entity that\r
+                   contain a property named "nodename"\r
+\r
+  [name=value]     Selects all the elements from an JSON entity where\r
+                   the property "name" is equal to "value"\r
+\r
+  [name~value]     Selects all the elements from an JSON entity where\r
+                   the string property "name" is equal to "value" using\r
+                   case insensitive comparison.\r
+\r
+  [name<value]     Selects all the elements from an JSON entity where\r
+                   the property "name" is less than "value"\r
+\r
+  [name<=value]    Selects all the elements from an JSON entity where\r
+                   the property "name" is less than or equal to "value"\r
+\r
+  [name>value]     Selects all the elements from an JSON entity where\r
+                   the property "name" is greater than "value"\r
+\r
+  [name>=value]    Selects all the elements from an JSON entity where\r
+                   the property "name" is greater than or equal to "value"\r
+\r
+  Some examples:\r
+\r
+    /v1/Chassis[1]        - Will return the first Chassis instance.\r
+    /v1/Chassis[SKU=1234] - Will return all Chassis instances with a SKU field equal to 1234.\r
+    /v1/Systems[Storage]  - Will return all the System instances that have Storage field populated.\r
+\r
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef REDFISH_LIB_H_\r
+#define REDFISH_LIB_H_\r
+\r
+#include <Library/JsonLib.h>\r
+\r
+#include <Protocol/Http.h>\r
+#include <Protocol/EdkIIRedfishConfigHandler.h>\r
+\r
+#define ODATA_TYPE_NAME_MAX_SIZE  128\r
+#define ODATA_TYPE_MAX_SIZE       128\r
+\r
+///\r
+/// Library class public defines\r
+///\r
+typedef  VOID  *REDFISH_SERVICE;\r
+typedef  VOID  *REDFISH_PAYLOAD;\r
+\r
+///\r
+/// Library class public structures/unions\r
+///\r
+typedef struct {\r
+  EFI_HTTP_STATUS_CODE    *StatusCode;\r
+  UINTN                   HeaderCount;\r
+  EFI_HTTP_HEADER         *Headers;\r
+  REDFISH_PAYLOAD         Payload;\r
+} REDFISH_RESPONSE;\r
+\r
+///\r
+/// Odata type-name mapping structure.\r
+///\r
+typedef struct {\r
+  CONST CHAR8    OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];\r
+  CONST CHAR8    OdataType[ODATA_TYPE_MAX_SIZE];\r
+} REDFISH_ODATA_TYPE_MAPPING;\r
+\r
+/**\r
+  This function uses REST EX protocol provided in RedfishConfigServiceInfo.\r
+  The service enumerator will also handle the authentication flow automatically\r
+  if HTTP basic auth or Redfish session login is configured to use.\r
+\r
+  Callers are responsible for freeing the returned service by RedfishCleanupService().\r
+\r
+  @param[in]  RedfishConfigServiceInfo Redfish service information the EFI Redfish\r
+                                       feature driver communicates with.\r
+\r
+  @return     New created Redfish Service, or NULL if error happens.\r
+\r
+**/\r
+REDFISH_SERVICE\r
+EFIAPI\r
+RedfishCreateService (\r
+  IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo\r
+  );\r
+\r
+/**\r
+  Free the Service and all its related resources.\r
+\r
+  @param[in]    RedfishService     The Service to access the Redfish resources.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+RedfishCleanupService (\r
+  IN REDFISH_SERVICE  RedfishService\r
+  );\r
+\r
+/**\r
+  Create REDFISH_PAYLOAD instance in local with JSON represented resource value and\r
+  the Redfish Service.\r
+\r
+  The returned REDFISH_PAYLOAD can be used to create or update Redfish resource in\r
+  server side.\r
+\r
+  Callers are responsible for freeing the returned payload by RedfishCleanupPayload().\r
+\r
+  @param[in]    Value                 JSON Value of the redfish resource.\r
+  @param[in]    RedfishService        The Service to access the Redfish resources.\r
+\r
+  @return     REDFISH_PAYLOAD instance of the resource, or NULL if error happens.\r
+\r
+**/\r
+REDFISH_PAYLOAD\r
+EFIAPI\r
+RedfishCreatePayload (\r
+  IN EDKII_JSON_VALUE  Value,\r
+  IN REDFISH_SERVICE   RedfishService\r
+  );\r
+\r
+/**\r
+  Free the RedfishPayload and all its related resources.\r
+\r
+  @param[in]    Payload        Payload to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+RedfishCleanupPayload (\r
+  IN REDFISH_PAYLOAD  Payload\r
+  );\r
+\r
+/**\r
+  This function returns the decoded JSON value of a REDFISH_PAYLOAD.\r
+\r
+  Caller doesn't need to free the returned JSON value because it will be released\r
+  in corresponding RedfishCleanupPayload() function.\r
+\r
+  @param[in]    Payload     A REDFISH_PAYLOAD instance.\r
+\r
+  @return     Decoded JSON value of the payload.\r
+\r
+**/\r
+EDKII_JSON_VALUE\r
+EFIAPI\r
+RedfishJsonInPayload (\r
+  IN REDFISH_PAYLOAD  Payload\r
+  );\r
+\r
+/**\r
+  Fill the input RedPath string with system UUID from SMBIOS table or use the customized\r
+  ID if  FromSmbios == FALSE.\r
+\r
+  This is a helper function to build a RedPath string which can be used to address\r
+  a Redfish resource for this computer system. The input PathString must have a Systems\r
+  note in format of "Systems[UUID=%g]" or "Systems[UUID~%g]" to fill the UUID value.\r
+\r
+  Example:\r
+    Use "/v1/Systems[UUID=%g]/Bios" to build a RedPath to address the "Bios" resource\r
+    for this computer system.\r
+\r
+  @param[in]    RedPath        RedPath format to be build.\r
+  @param[in]    FromSmbios     Get system UUID from SMBIOS as computer system instance ID.\r
+  @param[in]    IdString       The computer system instance ID.\r
+\r
+  @return     Full RedPath with system UUID inside, or NULL if error happens.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+RedfishBuildPathWithSystemUuid (\r
+  IN CONST CHAR8  *RedPath,\r
+  IN BOOLEAN      FromSmbios,\r
+  IN CHAR8        *IdString OPTIONAL\r
+  );\r
+\r
+/**\r
+  Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers\r
+  and Payload which record any HTTP response messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    RedfishService        The Service to access the Redfish resources.\r
+  @param[in]    RedPath               RedPath string to address a resource, must start\r
+                                      from the root node.\r
+  @param[out]   RedResponse           Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX. The corresponding redfish resource has\r
+                                  been returned in Payload within RedResponse.\r
+  @retval EFI_INVALID_PARAMETER   RedfishService, RedPath, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned Payload is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  3. If the returned StatusCode is not 2XX, indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishGetByService (\r
+  IN     REDFISH_SERVICE   RedfishService,\r
+  IN     CONST CHAR8       *RedPath,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Get a redfish response addressed by URI, including HTTP StatusCode, Headers\r
+  and Payload which record any HTTP response messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    RedfishService    The Service to access the URI resources.\r
+  @param[in]    URI               String to address a resource.\r
+  @param[out]   RedResponse       Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX. The corresponding redfish resource has\r
+                                  been returned in Payload within RedResponse.\r
+  @retval EFI_INVALID_PARAMETER   RedfishService, RedPath, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned Payload is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  3. If the returned StatusCode is not 2XX, indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishGetByUri (\r
+  IN     REDFISH_SERVICE   RedfishService,\r
+  IN     CONST CHAR8       *Uri,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Get a redfish response addressed by the input Payload and relative RedPath string,\r
+  including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    Payload           A existing REDFISH_PAYLOAD instance.\r
+  @param[in]    RedPath           Relative RedPath string to address a resource inside Payload.\r
+  @param[out]   RedResponse       Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful:\r
+                                  1. The HTTP StatusCode is NULL and the returned Payload in\r
+                                  RedResponse is not NULL, indicates the Redfish resource has\r
+                                  been parsed from the input payload directly.\r
+                                  2. The HTTP StatusCode is not NULL and the value is 2XX,\r
+                                  indicates the corresponding redfish resource has been returned\r
+                                  in Payload within RedResponse.\r
+  @retval EFI_INVALID_PARAMETER   Payload, RedPath, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned Payload is NULL, indicates any error happen.\r
+                                  2. If StatusCode is not NULL and the returned value of StatusCode\r
+                                     is not 2XX, indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishGetByPayload (\r
+  IN     REDFISH_PAYLOAD   Payload,\r
+  IN     CONST CHAR8       *RedPath,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Use HTTP PATCH to perform updates on pre-existing Redfish resource.\r
+\r
+  This function uses the RedfishService to patch a Redfish resource addressed by\r
+  Uri (only the relative path is required). Changes to one or more properties within\r
+  the target resource are represented in the input Content, properties not specified\r
+  in Content won't be changed by this request. The corresponding redfish response will\r
+  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
+  messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    RedfishService        The Service to access the Redfish resources.\r
+  @param[in]    Uri                   Relative path to address the resource.\r
+  @param[in]    Content               JSON represented properties to be update.\r
+  @param[out]   RedResponse           Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX. The Redfish resource will be returned\r
+                                  in Payload within RedResponse if server send it back in the HTTP\r
+                                  response message body.\r
+  @retval EFI_INVALID_PARAMETER   RedfishService, Uri, Content, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
+                                     indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishPatchToUri (\r
+  IN     REDFISH_SERVICE   RedfishService,\r
+  IN     CONST CHAR8       *Uri,\r
+  IN     CONST CHAR8       *Content,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.\r
+\r
+  This function uses the Payload to patch the Target. Changes to one or more properties\r
+  within the target resource are represented in the input Payload, properties not specified\r
+  in Payload won't be changed by this request. The corresponding redfish response will\r
+  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
+  messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    Target           The target payload to be updated.\r
+  @param[in]    Payload          Palyoad with properties to be changed.\r
+  @param[out]   RedResponse      Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX. The Redfish resource will be returned\r
+                                  in Payload within RedResponse if server send it back in the HTTP\r
+                                  response message body.\r
+  @retval EFI_INVALID_PARAMETER   Target, Payload, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
+                                     indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishPatchToPayload (\r
+  IN     REDFISH_PAYLOAD   Target,\r
+  IN     REDFISH_PAYLOAD   Payload,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Use HTTP POST to create a new resource in target payload.\r
+\r
+  The POST request should be submitted to the Resource Collection in which the new resource\r
+  is to belong. The Resource Collection is addressed by Target payload. The Redfish may\r
+  ignore any service controlled properties. The corresponding redfish response will returned,\r
+  including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    Target          Target payload of the Resource Collection.\r
+  @param[in]    Payload         The new resource to be created.\r
+  @param[out]   RedResponse     Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX. The Redfish resource will be returned\r
+                                  in Payload within RedResponse if server send it back in the HTTP\r
+                                  response message body.\r
+  @retval EFI_INVALID_PARAMETER   Target, Payload, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
+                                     indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishPostToPayload (\r
+  IN     REDFISH_PAYLOAD   Target,\r
+  IN     REDFISH_PAYLOAD   Payload,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Use HTTP DELETE to remove a resource.\r
+\r
+  This function uses the RedfishService to remove a Redfish resource which is addressed\r
+  by input Uri (only the relative path is required). The corresponding redfish response will\r
+  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
+  messages.\r
+\r
+  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
+  redfish response data.\r
+\r
+  @param[in]    RedfishService        The Service to access the Redfish resources.\r
+  @param[in]    Uri                   Relative path to address the resource.\r
+  @param[out]   RedResponse           Pointer to the Redfish response data.\r
+\r
+  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
+                                  NULL and the value is 2XX, the Redfish resource has been removed.\r
+                                  If there is any message returned from server, it will be returned\r
+                                  in Payload within RedResponse.\r
+  @retval EFI_INVALID_PARAMETER   RedfishService, Uri, or RedResponse is NULL.\r
+  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
+                                  more error info from returned HTTP StatusCode, Headers and Payload\r
+                                  within RedResponse:\r
+                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
+                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
+                                     indicates any error happen.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RedfishDeleteByUri (\r
+  IN     REDFISH_SERVICE   RedfishService,\r
+  IN     CONST CHAR8       *Uri,\r
+  OUT    REDFISH_RESPONSE  *RedResponse\r
+  );\r
+\r
+/**\r
+  Dump text in fractions.\r
+\r
+  @param[in]  String   ASCII string to dump.\r
+\r
+**/\r
+VOID\r
+RedfishDumpJsonStringFractions (\r
+  IN CHAR8  *String\r
+  );\r
+\r
+/**\r
+  Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.\r
+\r
+  @param[in]  Payload       The Redfish payload to dump.\r
+\r
+**/\r
+VOID\r
+RedfishDumpPayload (\r
+  IN REDFISH_PAYLOAD  Payload\r
+  );\r
+\r
+/**\r
+  Dump text in JSON value.\r
+\r
+  @param[in]  JsonValue       The Redfish JSON value to dump.\r
+\r
+**/\r
+VOID\r
+RedfishDumpJson (\r
+  IN EDKII_JSON_VALUE  JsonValue\r
+  );\r
+\r
+/**\r
+  This function will cleanup the HTTP header and Redfish payload resources.\r
+\r
+  @param[in]  StatusCode        The status code in HTTP response message.\r
+  @param[in]  HeaderCount       Number of HTTP header structures in Headers list.\r
+  @param[in]  Headers           Array containing list of HTTP headers.\r
+  @param[in]  Payload           The Redfish payload to dump.\r
+\r
+**/\r
+VOID\r
+RedfishFreeResponse (\r
+  IN EFI_HTTP_STATUS_CODE  *StatusCode,\r
+  IN UINTN                 HeaderCount,\r
+  IN EFI_HTTP_HEADER       *Headers,\r
+  IN REDFISH_PAYLOAD       Payload\r
+  );\r
+\r
+/**\r
+  Check if the "@odata.type" in Payload is valid or not.\r
+\r
+  @param[in]  Payload                  The Redfish payload to be checked.\r
+  @param[in]  OdataTypeName            OdataType will be retrived from mapping list.\r
+  @param[in]  OdataTypeMappingList     The list of OdataType.\r
+  @param[in]  OdataTypeMappingListSize The number of mapping list\r
+\r
+  @return TRUE if the "@odata.type" in Payload is valid, otherwise FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+RedfishIsValidOdataType (\r
+  IN REDFISH_PAYLOAD             Payload,\r
+  IN CONST CHAR8                 *OdataTypeName,\r
+  IN REDFISH_ODATA_TYPE_MAPPING  *OdataTypeMappingList,\r
+  IN UINTN                       OdataTypeMappingListSize\r
+  );\r
+\r
+/**\r
+  Check if the payload is collection\r
+\r
+  @param[in]  Payload   The Redfish payload to be checked.\r
+\r
+  @return TRUE if the payload is  collection.\r
+\r
+**/\r
+BOOLEAN\r
+RedfishIsPayloadCollection (\r
+  IN REDFISH_PAYLOAD  Payload\r
+  );\r
+\r
+/**\r
+  Get collection size.\r
+\r
+  @param[in]  Payload         The Redfish collection payload\r
+  @param[in]  CollectionSize  Size of this collection\r
+\r
+  @return EFI_SUCCESS              Coolection size is returned in CollectionSize\r
+  @return EFI_INVALID_PARAMETER    The payload is not a collection.\r
+**/\r
+EFI_STATUS\r
+RedfishGetCollectionSize (\r
+  IN REDFISH_PAYLOAD  Payload,\r
+  IN UINTN            *CollectionSize\r
+  );\r
+\r
+/**\r
+  Get Redfish payload of collection member\r
+\r
+  @param[in]  Payload    The Redfish collection payload\r
+  @param[in]  Index      Index of collection member\r
+\r
+  @return NULL           Fail to get collection member.\r
+  @return Non NULL       Payload is returned.\r
+**/\r
+REDFISH_PAYLOAD\r
+RedfishGetPayloadByIndex (\r
+  IN REDFISH_PAYLOAD  Payload,\r
+  IN UINTN            Index\r
+  );\r
+\r
+/**\r
+  Check and return Redfish resource of the given Redpath.\r
+\r
+  @param[in]  RedfishService  Pointer to REDFISH_SERVICE\r
+  @param[in]  Redpath         Redpath of the resource.\r
+  @param[in]  Response        Optional return the resource.\r
+\r
+  @return EFI_STATUS\r
+**/\r
+EFI_STATUS\r
+RedfishCheckIfRedpathExist (\r
+  IN REDFISH_SERVICE   RedfishService,\r
+  IN CHAR8             *Redpath,\r
+  IN REDFISH_RESPONSE  *Response OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function returns the string of Redfish service version.\r
+\r
+  @param[in]  RedfishService      Redfish service instance.\r
+  @param[out] ServiceVersionStr   Redfish service string.\r
+\r
+  @return     EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+RedfishGetServiceVersion (\r
+  IN  REDFISH_SERVICE  RedfishService,\r
+  OUT CHAR8            **ServiceVersionStr\r
+  );\r
+\r
+/**\r
+  This function returns the string of Redfish service version.\r
+\r
+  @param[in]   ServiceVerisonStr The string of Redfish service version.\r
+  @param[in]   Url               The URL to build Redpath with ID.\r
+                                 Start with "/", for example "/Registries"\r
+  @param[in]   Id                ID string\r
+  @param[out]  Redpath           Pointer to retrive Redpath, caller has to free\r
+                                 the memory allocated for this string.\r
+  @return     EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+RedfishBuildRedpathUseId (\r
+  IN  CHAR8  *ServiceVerisonStr,\r
+  IN  CHAR8  *Url,\r
+  IN  CHAR8  *Id,\r
+  OUT CHAR8  **Redpath\r
+  );\r
+\r
+#endif\r
diff --git a/RedfishPkg/PrivateInclude/Library/RedfishLib.h b/RedfishPkg/PrivateInclude/Library/RedfishLib.h
deleted file mode 100644 (file)
index b2488ab..0000000
+++ /dev/null
@@ -1,616 +0,0 @@
-/** @file\r
-  This library provides a set of utility APIs that allow to create/read/update/delete\r
-  (CRUD) Redfish resources and provide basic query abilities by using [URI/RedPath]\r
-  (https://github.com/DMTF/libredfish).\r
-\r
-  The query language is based on XPath (https://www.w3.org/TR/1999/REC-xpath-19991116/).\r
-  This library and query language essentially treat the entire Redfish Service like it\r
-  was a single JSON document. In other words whenever it encounters an odata.id in JSON\r
-  document, it will retrieve the new JSON document (if needed). We name the path as\r
-  RedPath:\r
-\r
-  Expression       Description\r
-\r
-  nodename         Selects the JSON entity with the name "nodename".\r
-                   If the value of nodename is an object with "@odata.id",\r
-                   it will continue get the value from "@odata.id".\r
-\r
-  /                Selects from the root node\r
-\r
-  [index]           Selects the index number JSON entity from an array or\r
-                   object. If the JSON entity is one collection (has\r
-                   Members & Members@odata.count), means to get the index\r
-                   member in "Members". Index number >=1, 1 means to return\r
-                   the first instance.\r
-\r
-  [XXX]            Operation on JSON entity.\r
-                   If the JSON entity is one collection (has Members &\r
-                   Members@odata.count), means to get all elements in\r
-                   "Members". If the JSON entity is one array, means to\r
-                   get all elements in array. Others will match the nodename\r
-                   directly (e.g. JSON_OBJECT, JSON_STRING, JSON_TRUE,\r
-                   JSON_FALSE, JSON_INTEGER).\r
-\r
-  [nodename]       Selects all the elements from an JSON entity that\r
-                   contain a property named "nodename"\r
-\r
-  [name=value]     Selects all the elements from an JSON entity where\r
-                   the property "name" is equal to "value"\r
-\r
-  [name~value]     Selects all the elements from an JSON entity where\r
-                   the string property "name" is equal to "value" using\r
-                   case insensitive comparison.\r
-\r
-  [name<value]     Selects all the elements from an JSON entity where\r
-                   the property "name" is less than "value"\r
-\r
-  [name<=value]    Selects all the elements from an JSON entity where\r
-                   the property "name" is less than or equal to "value"\r
-\r
-  [name>value]     Selects all the elements from an JSON entity where\r
-                   the property "name" is greater than "value"\r
-\r
-  [name>=value]    Selects all the elements from an JSON entity where\r
-                   the property "name" is greater than or equal to "value"\r
-\r
-  Some examples:\r
-\r
-    /v1/Chassis[1]        - Will return the first Chassis instance.\r
-    /v1/Chassis[SKU=1234] - Will return all Chassis instances with a SKU field equal to 1234.\r
-    /v1/Systems[Storage]  - Will return all the System instances that have Storage field populated.\r
-\r
-  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
-\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef REDFISH_LIB_H_\r
-#define REDFISH_LIB_H_\r
-\r
-#include <Library/JsonLib.h>\r
-\r
-#include <Protocol/Http.h>\r
-#include <Protocol/EdkIIRedfishConfigHandler.h>\r
-\r
-#define ODATA_TYPE_NAME_MAX_SIZE  128\r
-#define ODATA_TYPE_MAX_SIZE       128\r
-\r
-///\r
-/// Library class public defines\r
-///\r
-typedef  VOID  *REDFISH_SERVICE;\r
-typedef  VOID  *REDFISH_PAYLOAD;\r
-\r
-///\r
-/// Library class public structures/unions\r
-///\r
-typedef struct {\r
-  EFI_HTTP_STATUS_CODE    *StatusCode;\r
-  UINTN                   HeaderCount;\r
-  EFI_HTTP_HEADER         *Headers;\r
-  REDFISH_PAYLOAD         Payload;\r
-} REDFISH_RESPONSE;\r
-\r
-///\r
-/// Odata type-name mapping structure.\r
-///\r
-typedef struct {\r
-  CONST CHAR8    OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];\r
-  CONST CHAR8    OdataType[ODATA_TYPE_MAX_SIZE];\r
-} REDFISH_ODATA_TYPE_MAPPING;\r
-\r
-/**\r
-  This function uses REST EX protocol provided in RedfishConfigServiceInfo.\r
-  The service enumerator will also handle the authentication flow automatically\r
-  if HTTP basic auth or Redfish session login is configured to use.\r
-\r
-  Callers are responsible for freeing the returned service by RedfishCleanupService().\r
-\r
-  @param[in]  RedfishConfigServiceInfo Redfish service information the EFI Redfish\r
-                                       feature driver communicates with.\r
-\r
-  @return     New created Redfish Service, or NULL if error happens.\r
-\r
-**/\r
-REDFISH_SERVICE\r
-EFIAPI\r
-RedfishCreateService (\r
-  IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo\r
-  );\r
-\r
-/**\r
-  Free the Service and all its related resources.\r
-\r
-  @param[in]    RedfishService     The Service to access the Redfish resources.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-RedfishCleanupService (\r
-  IN REDFISH_SERVICE  RedfishService\r
-  );\r
-\r
-/**\r
-  Create REDFISH_PAYLOAD instance in local with JSON represented resource value and\r
-  the Redfish Service.\r
-\r
-  The returned REDFISH_PAYLOAD can be used to create or update Redfish resource in\r
-  server side.\r
-\r
-  Callers are responsible for freeing the returned payload by RedfishCleanupPayload().\r
-\r
-  @param[in]    Value                 JSON Value of the redfish resource.\r
-  @param[in]    RedfishService        The Service to access the Redfish resources.\r
-\r
-  @return     REDFISH_PAYLOAD instance of the resource, or NULL if error happens.\r
-\r
-**/\r
-REDFISH_PAYLOAD\r
-EFIAPI\r
-RedfishCreatePayload (\r
-  IN EDKII_JSON_VALUE  Value,\r
-  IN REDFISH_SERVICE   RedfishService\r
-  );\r
-\r
-/**\r
-  Free the RedfishPayload and all its related resources.\r
-\r
-  @param[in]    Payload        Payload to be freed.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-RedfishCleanupPayload (\r
-  IN REDFISH_PAYLOAD  Payload\r
-  );\r
-\r
-/**\r
-  This function returns the decoded JSON value of a REDFISH_PAYLOAD.\r
-\r
-  Caller doesn't need to free the returned JSON value because it will be released\r
-  in corresponding RedfishCleanupPayload() function.\r
-\r
-  @param[in]    Payload     A REDFISH_PAYLOAD instance.\r
-\r
-  @return     Decoded JSON value of the payload.\r
-\r
-**/\r
-EDKII_JSON_VALUE\r
-EFIAPI\r
-RedfishJsonInPayload (\r
-  IN REDFISH_PAYLOAD  Payload\r
-  );\r
-\r
-/**\r
-  Fill the input RedPath string with system UUID from SMBIOS table or use the customized\r
-  ID if  FromSmbios == FALSE.\r
-\r
-  This is a helper function to build a RedPath string which can be used to address\r
-  a Redfish resource for this computer system. The input PathString must have a Systems\r
-  note in format of "Systems[UUID=%g]" or "Systems[UUID~%g]" to fill the UUID value.\r
-\r
-  Example:\r
-    Use "/v1/Systems[UUID=%g]/Bios" to build a RedPath to address the "Bios" resource\r
-    for this computer system.\r
-\r
-  @param[in]    RedPath        RedPath format to be build.\r
-  @param[in]    FromSmbios     Get system UUID from SMBIOS as computer system instance ID.\r
-  @param[in]    IdString       The computer system instance ID.\r
-\r
-  @return     Full RedPath with system UUID inside, or NULL if error happens.\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-RedfishBuildPathWithSystemUuid (\r
-  IN CONST CHAR8  *RedPath,\r
-  IN BOOLEAN      FromSmbios,\r
-  IN CHAR8        *IdString OPTIONAL\r
-  );\r
-\r
-/**\r
-  Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers\r
-  and Payload which record any HTTP response messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    RedfishService        The Service to access the Redfish resources.\r
-  @param[in]    RedPath               RedPath string to address a resource, must start\r
-                                      from the root node.\r
-  @param[out]   RedResponse           Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX. The corresponding redfish resource has\r
-                                  been returned in Payload within RedResponse.\r
-  @retval EFI_INVALID_PARAMETER   RedfishService, RedPath, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned Payload is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  3. If the returned StatusCode is not 2XX, indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishGetByService (\r
-  IN     REDFISH_SERVICE   RedfishService,\r
-  IN     CONST CHAR8       *RedPath,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Get a redfish response addressed by URI, including HTTP StatusCode, Headers\r
-  and Payload which record any HTTP response messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    RedfishService    The Service to access the URI resources.\r
-  @param[in]    URI               String to address a resource.\r
-  @param[out]   RedResponse       Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX. The corresponding redfish resource has\r
-                                  been returned in Payload within RedResponse.\r
-  @retval EFI_INVALID_PARAMETER   RedfishService, RedPath, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned Payload is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  3. If the returned StatusCode is not 2XX, indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishGetByUri (\r
-  IN     REDFISH_SERVICE   RedfishService,\r
-  IN     CONST CHAR8       *Uri,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Get a redfish response addressed by the input Payload and relative RedPath string,\r
-  including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    Payload           A existing REDFISH_PAYLOAD instance.\r
-  @param[in]    RedPath           Relative RedPath string to address a resource inside Payload.\r
-  @param[out]   RedResponse       Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful:\r
-                                  1. The HTTP StatusCode is NULL and the returned Payload in\r
-                                  RedResponse is not NULL, indicates the Redfish resource has\r
-                                  been parsed from the input payload directly.\r
-                                  2. The HTTP StatusCode is not NULL and the value is 2XX,\r
-                                  indicates the corresponding redfish resource has been returned\r
-                                  in Payload within RedResponse.\r
-  @retval EFI_INVALID_PARAMETER   Payload, RedPath, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned Payload is NULL, indicates any error happen.\r
-                                  2. If StatusCode is not NULL and the returned value of StatusCode\r
-                                     is not 2XX, indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishGetByPayload (\r
-  IN     REDFISH_PAYLOAD   Payload,\r
-  IN     CONST CHAR8       *RedPath,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Use HTTP PATCH to perform updates on pre-existing Redfish resource.\r
-\r
-  This function uses the RedfishService to patch a Redfish resource addressed by\r
-  Uri (only the relative path is required). Changes to one or more properties within\r
-  the target resource are represented in the input Content, properties not specified\r
-  in Content won't be changed by this request. The corresponding redfish response will\r
-  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
-  messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    RedfishService        The Service to access the Redfish resources.\r
-  @param[in]    Uri                   Relative path to address the resource.\r
-  @param[in]    Content               JSON represented properties to be update.\r
-  @param[out]   RedResponse           Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX. The Redfish resource will be returned\r
-                                  in Payload within RedResponse if server send it back in the HTTP\r
-                                  response message body.\r
-  @retval EFI_INVALID_PARAMETER   RedfishService, Uri, Content, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
-                                     indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishPatchToUri (\r
-  IN     REDFISH_SERVICE   RedfishService,\r
-  IN     CONST CHAR8       *Uri,\r
-  IN     CONST CHAR8       *Content,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.\r
-\r
-  This function uses the Payload to patch the Target. Changes to one or more properties\r
-  within the target resource are represented in the input Payload, properties not specified\r
-  in Payload won't be changed by this request. The corresponding redfish response will\r
-  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
-  messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    Target           The target payload to be updated.\r
-  @param[in]    Payload          Palyoad with properties to be changed.\r
-  @param[out]   RedResponse      Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX. The Redfish resource will be returned\r
-                                  in Payload within RedResponse if server send it back in the HTTP\r
-                                  response message body.\r
-  @retval EFI_INVALID_PARAMETER   Target, Payload, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
-                                     indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishPatchToPayload (\r
-  IN     REDFISH_PAYLOAD   Target,\r
-  IN     REDFISH_PAYLOAD   Payload,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Use HTTP POST to create a new resource in target payload.\r
-\r
-  The POST request should be submitted to the Resource Collection in which the new resource\r
-  is to belong. The Resource Collection is addressed by Target payload. The Redfish may\r
-  ignore any service controlled properties. The corresponding redfish response will returned,\r
-  including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    Target          Target payload of the Resource Collection.\r
-  @param[in]    Payload         The new resource to be created.\r
-  @param[out]   RedResponse     Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX. The Redfish resource will be returned\r
-                                  in Payload within RedResponse if server send it back in the HTTP\r
-                                  response message body.\r
-  @retval EFI_INVALID_PARAMETER   Target, Payload, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
-                                     indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishPostToPayload (\r
-  IN     REDFISH_PAYLOAD   Target,\r
-  IN     REDFISH_PAYLOAD   Payload,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Use HTTP DELETE to remove a resource.\r
-\r
-  This function uses the RedfishService to remove a Redfish resource which is addressed\r
-  by input Uri (only the relative path is required). The corresponding redfish response will\r
-  returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r
-  messages.\r
-\r
-  Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r
-  redfish response data.\r
-\r
-  @param[in]    RedfishService        The Service to access the Redfish resources.\r
-  @param[in]    Uri                   Relative path to address the resource.\r
-  @param[out]   RedResponse           Pointer to the Redfish response data.\r
-\r
-  @retval EFI_SUCCESS             The opeartion is successful, indicates the HTTP StatusCode is not\r
-                                  NULL and the value is 2XX, the Redfish resource has been removed.\r
-                                  If there is any message returned from server, it will be returned\r
-                                  in Payload within RedResponse.\r
-  @retval EFI_INVALID_PARAMETER   RedfishService, Uri, or RedResponse is NULL.\r
-  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred. Callers can get\r
-                                  more error info from returned HTTP StatusCode, Headers and Payload\r
-                                  within RedResponse:\r
-                                  1. If the returned StatusCode is NULL, indicates any error happen.\r
-                                  2. If the returned StatusCode is not NULL and the value is not 2XX,\r
-                                     indicates any error happen.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RedfishDeleteByUri (\r
-  IN     REDFISH_SERVICE   RedfishService,\r
-  IN     CONST CHAR8       *Uri,\r
-  OUT    REDFISH_RESPONSE  *RedResponse\r
-  );\r
-\r
-/**\r
-  Dump text in fractions.\r
-\r
-  @param[in]  String   ASCII string to dump.\r
-\r
-**/\r
-VOID\r
-RedfishDumpJsonStringFractions (\r
-  IN CHAR8  *String\r
-  );\r
-\r
-/**\r
-  Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.\r
-\r
-  @param[in]  Payload       The Redfish payload to dump.\r
-\r
-**/\r
-VOID\r
-RedfishDumpPayload (\r
-  IN REDFISH_PAYLOAD  Payload\r
-  );\r
-\r
-/**\r
-  Dump text in JSON value.\r
-\r
-  @param[in]  JsonValue       The Redfish JSON value to dump.\r
-\r
-**/\r
-VOID\r
-RedfishDumpJson (\r
-  IN EDKII_JSON_VALUE  JsonValue\r
-  );\r
-\r
-/**\r
-  This function will cleanup the HTTP header and Redfish payload resources.\r
-\r
-  @param[in]  StatusCode        The status code in HTTP response message.\r
-  @param[in]  HeaderCount       Number of HTTP header structures in Headers list.\r
-  @param[in]  Headers           Array containing list of HTTP headers.\r
-  @param[in]  Payload           The Redfish payload to dump.\r
-\r
-**/\r
-VOID\r
-RedfishFreeResponse (\r
-  IN EFI_HTTP_STATUS_CODE  *StatusCode,\r
-  IN UINTN                 HeaderCount,\r
-  IN EFI_HTTP_HEADER       *Headers,\r
-  IN REDFISH_PAYLOAD       Payload\r
-  );\r
-\r
-/**\r
-  Check if the "@odata.type" in Payload is valid or not.\r
-\r
-  @param[in]  Payload                  The Redfish payload to be checked.\r
-  @param[in]  OdataTypeName            OdataType will be retrived from mapping list.\r
-  @param[in]  OdataTypeMappingList     The list of OdataType.\r
-  @param[in]  OdataTypeMappingListSize The number of mapping list\r
-\r
-  @return TRUE if the "@odata.type" in Payload is valid, otherwise FALSE.\r
-\r
-**/\r
-BOOLEAN\r
-RedfishIsValidOdataType (\r
-  IN REDFISH_PAYLOAD             Payload,\r
-  IN CONST CHAR8                 *OdataTypeName,\r
-  IN REDFISH_ODATA_TYPE_MAPPING  *OdataTypeMappingList,\r
-  IN UINTN                       OdataTypeMappingListSize\r
-  );\r
-\r
-/**\r
-  Check if the payload is collection\r
-\r
-  @param[in]  Payload   The Redfish payload to be checked.\r
-\r
-  @return TRUE if the payload is  collection.\r
-\r
-**/\r
-BOOLEAN\r
-RedfishIsPayloadCollection (\r
-  IN REDFISH_PAYLOAD  Payload\r
-  );\r
-\r
-/**\r
-  Get collection size.\r
-\r
-  @param[in]  Payload         The Redfish collection payload\r
-  @param[in]  CollectionSize  Size of this collection\r
-\r
-  @return EFI_SUCCESS              Coolection size is returned in CollectionSize\r
-  @return EFI_INVALID_PARAMETER    The payload is not a collection.\r
-**/\r
-EFI_STATUS\r
-RedfishGetCollectionSize (\r
-  IN REDFISH_PAYLOAD  Payload,\r
-  IN UINTN            *CollectionSize\r
-  );\r
-\r
-/**\r
-  Get Redfish payload of collection member\r
-\r
-  @param[in]  Payload    The Redfish collection payload\r
-  @param[in]  Index      Index of collection member\r
-\r
-  @return NULL           Fail to get collection member.\r
-  @return Non NULL       Payload is returned.\r
-**/\r
-REDFISH_PAYLOAD\r
-RedfishGetPayloadByIndex (\r
-  IN REDFISH_PAYLOAD  Payload,\r
-  IN UINTN            Index\r
-  );\r
-\r
-/**\r
-  Check and return Redfish resource of the given Redpath.\r
-\r
-  @param[in]  RedfishService  Pointer to REDFISH_SERVICE\r
-  @param[in]  Redpath         Redpath of the resource.\r
-  @param[in]  Response        Optional return the resource.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-RedfishCheckIfRedpathExist (\r
-  IN REDFISH_SERVICE   RedfishService,\r
-  IN CHAR8             *Redpath,\r
-  IN REDFISH_RESPONSE  *Response OPTIONAL\r
-  );\r
-\r
-/**\r
-  This function returns the string of Redfish service version.\r
-\r
-  @param[in]  RedfishService      Redfish service instance.\r
-  @param[out] ServiceVersionStr   Redfish service string.\r
-\r
-  @return     EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-RedfishGetServiceVersion (\r
-  IN  REDFISH_SERVICE  RedfishService,\r
-  OUT CHAR8            **ServiceVersionStr\r
-  );\r
-\r
-/**\r
-  This function returns the string of Redfish service version.\r
-\r
-  @param[in]   ServiceVerisonStr The string of Redfish service version.\r
-  @param[in]   Url               The URL to build Redpath with ID.\r
-                                 Start with "/", for example "/Registries"\r
-  @param[in]   Id                ID string\r
-  @param[out]  Redpath           Pointer to retrive Redpath, caller has to free\r
-                                 the memory allocated for this string.\r
-  @return     EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-RedfishBuildRedpathUseId (\r
-  IN  CHAR8  *ServiceVerisonStr,\r
-  IN  CHAR8  *Url,\r
-  IN  CHAR8  *Id,\r
-  OUT CHAR8  **Redpath\r
-  );\r
-\r
-#endif\r
index 9886502a0db5446ba8f5c699573f3a0263c1e4a9..0aa26883e2202860f9da1bc50e25357eef93f551 100644 (file)
@@ -64,7 +64,7 @@
 \r
   ##  @libraryclass Redfish Helper Library\r
   #   Library provides Redfish helper functions.\r
-  RedfishLib|PrivateInclude/Library/RedfishLib.h\r
+  RedfishLib|Include/Library/RedfishLib.h\r
 \r
 [Protocols]\r
   ## Include/Protocol/EdkIIRedfishCredential.h\r