]>
Commit | Line | Data |
---|---|---|
4751a48a AC |
1 | /** @file\r |
2 | This library provides a set of utility APIs that allow to create/read/update/delete\r | |
3 | (CRUD) Redfish resources and provide basic query abilities by using [URI/RedPath]\r | |
4 | (https://github.com/DMTF/libredfish).\r | |
5 | \r | |
6 | The query language is based on XPath (https://www.w3.org/TR/1999/REC-xpath-19991116/).\r | |
7 | This library and query language essentially treat the entire Redfish Service like it\r | |
8 | was a single JSON document. In other words whenever it encounters an odata.id in JSON\r | |
9 | document, it will retrieve the new JSON document (if needed). We name the path as\r | |
10 | RedPath:\r | |
11 | \r | |
12 | Expression Description\r | |
13 | \r | |
14 | nodename Selects the JSON entity with the name "nodename".\r | |
15 | If the value of nodename is an object with "@odata.id",\r | |
16 | it will continue get the value from "@odata.id".\r | |
17 | \r | |
18 | / Selects from the root node\r | |
19 | \r | |
20 | [index] Selects the index number JSON entity from an array or\r | |
21 | object. If the JSON entity is one collection (has\r | |
22 | Members & Members@odata.count), means to get the index\r | |
23 | member in "Members". Index number >=1, 1 means to return\r | |
24 | the first instance.\r | |
25 | \r | |
26 | [XXX] Operation on JSON entity.\r | |
27 | If the JSON entity is one collection (has Members &\r | |
28 | Members@odata.count), means to get all elements in\r | |
29 | "Members". If the JSON entity is one array, means to\r | |
30 | get all elements in array. Others will match the nodename\r | |
31 | directly (e.g. JSON_OBJECT, JSON_STRING, JSON_TRUE,\r | |
32 | JSON_FALSE, JSON_INTEGER).\r | |
33 | \r | |
34 | [nodename] Selects all the elements from an JSON entity that\r | |
35 | contain a property named "nodename"\r | |
36 | \r | |
37 | [name=value] Selects all the elements from an JSON entity where\r | |
38 | the property "name" is equal to "value"\r | |
39 | \r | |
40 | [name~value] Selects all the elements from an JSON entity where\r | |
41 | the string property "name" is equal to "value" using\r | |
42 | case insensitive comparison.\r | |
43 | \r | |
44 | [name<value] Selects all the elements from an JSON entity where\r | |
45 | the property "name" is less than "value"\r | |
46 | \r | |
47 | [name<=value] Selects all the elements from an JSON entity where\r | |
48 | the property "name" is less than or equal to "value"\r | |
49 | \r | |
50 | [name>value] Selects all the elements from an JSON entity where\r | |
51 | the property "name" is greater than "value"\r | |
52 | \r | |
53 | [name>=value] Selects all the elements from an JSON entity where\r | |
54 | the property "name" is greater than or equal to "value"\r | |
55 | \r | |
56 | Some examples:\r | |
57 | \r | |
58 | /v1/Chassis[1] - Will return the first Chassis instance.\r | |
59 | /v1/Chassis[SKU=1234] - Will return all Chassis instances with a SKU field equal to 1234.\r | |
60 | /v1/Systems[Storage] - Will return all the System instances that have Storage field populated.\r | |
61 | \r | |
62 | Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r | |
63 | (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r | |
64 | \r | |
65 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
66 | \r | |
67 | **/\r | |
68 | \r | |
69 | #ifndef REDFISH_LIB_H_\r | |
70 | #define REDFISH_LIB_H_\r | |
71 | \r | |
72 | #include <Library/JsonLib.h>\r | |
73 | \r | |
74 | #include <Protocol/Http.h>\r | |
75 | #include <Protocol/EdkIIRedfishConfigHandler.h>\r | |
76 | \r | |
77 | #define ODATA_TYPE_NAME_MAX_SIZE 128\r | |
78 | #define ODATA_TYPE_MAX_SIZE 128\r | |
79 | \r | |
80 | ///\r | |
81 | /// Library class public defines\r | |
82 | ///\r | |
39de741e MK |
83 | typedef VOID *REDFISH_SERVICE;\r |
84 | typedef VOID *REDFISH_PAYLOAD;\r | |
4751a48a AC |
85 | \r |
86 | ///\r | |
87 | /// Library class public structures/unions\r | |
88 | ///\r | |
89 | typedef struct {\r | |
39de741e MK |
90 | EFI_HTTP_STATUS_CODE *StatusCode;\r |
91 | UINTN HeaderCount;\r | |
92 | EFI_HTTP_HEADER *Headers;\r | |
93 | REDFISH_PAYLOAD Payload;\r | |
4751a48a AC |
94 | } REDFISH_RESPONSE;\r |
95 | \r | |
96 | ///\r | |
97 | /// Odata type-name mapping structure.\r | |
98 | ///\r | |
99 | typedef struct {\r | |
39de741e MK |
100 | CONST CHAR8 OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];\r |
101 | CONST CHAR8 OdataType[ODATA_TYPE_MAX_SIZE];\r | |
4751a48a AC |
102 | } REDFISH_ODATA_TYPE_MAPPING;\r |
103 | \r | |
104 | /**\r | |
105 | This function uses REST EX protocol provided in RedfishConfigServiceInfo.\r | |
106 | The service enumerator will also handle the authentication flow automatically\r | |
107 | if HTTP basic auth or Redfish session login is configured to use.\r | |
108 | \r | |
109 | Callers are responsible for freeing the returned service by RedfishCleanupService().\r | |
110 | \r | |
111 | @param[in] RedfishConfigServiceInfo Redfish service information the EFI Redfish\r | |
112 | feature driver communicates with.\r | |
113 | \r | |
114 | @return New created Redfish Service, or NULL if error happens.\r | |
115 | \r | |
116 | **/\r | |
117 | REDFISH_SERVICE\r | |
118 | EFIAPI\r | |
119 | RedfishCreateService (\r | |
39de741e | 120 | IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo\r |
4751a48a AC |
121 | );\r |
122 | \r | |
123 | /**\r | |
124 | Free the Service and all its related resources.\r | |
125 | \r | |
126 | @param[in] RedfishService The Service to access the Redfish resources.\r | |
127 | \r | |
128 | **/\r | |
129 | VOID\r | |
130 | EFIAPI\r | |
131 | RedfishCleanupService (\r | |
39de741e | 132 | IN REDFISH_SERVICE RedfishService\r |
4751a48a AC |
133 | );\r |
134 | \r | |
135 | /**\r | |
136 | Create REDFISH_PAYLOAD instance in local with JSON represented resource value and\r | |
137 | the Redfish Service.\r | |
138 | \r | |
139 | The returned REDFISH_PAYLOAD can be used to create or update Redfish resource in\r | |
140 | server side.\r | |
141 | \r | |
142 | Callers are responsible for freeing the returned payload by RedfishCleanupPayload().\r | |
143 | \r | |
144 | @param[in] Value JSON Value of the redfish resource.\r | |
145 | @param[in] RedfishService The Service to access the Redfish resources.\r | |
146 | \r | |
147 | @return REDFISH_PAYLOAD instance of the resource, or NULL if error happens.\r | |
148 | \r | |
149 | **/\r | |
150 | REDFISH_PAYLOAD\r | |
151 | EFIAPI\r | |
152 | RedfishCreatePayload (\r | |
39de741e MK |
153 | IN EDKII_JSON_VALUE Value,\r |
154 | IN REDFISH_SERVICE RedfishService\r | |
4751a48a AC |
155 | );\r |
156 | \r | |
157 | /**\r | |
158 | Free the RedfishPayload and all its related resources.\r | |
159 | \r | |
160 | @param[in] Payload Payload to be freed.\r | |
161 | \r | |
162 | **/\r | |
163 | VOID\r | |
164 | EFIAPI\r | |
165 | RedfishCleanupPayload (\r | |
39de741e | 166 | IN REDFISH_PAYLOAD Payload\r |
4751a48a AC |
167 | );\r |
168 | \r | |
169 | /**\r | |
170 | This function returns the decoded JSON value of a REDFISH_PAYLOAD.\r | |
171 | \r | |
172 | Caller doesn't need to free the returned JSON value because it will be released\r | |
173 | in corresponding RedfishCleanupPayload() function.\r | |
174 | \r | |
175 | @param[in] Payload A REDFISH_PAYLOAD instance.\r | |
176 | \r | |
177 | @return Decoded JSON value of the payload.\r | |
178 | \r | |
179 | **/\r | |
180 | EDKII_JSON_VALUE\r | |
181 | EFIAPI\r | |
182 | RedfishJsonInPayload (\r | |
39de741e | 183 | IN REDFISH_PAYLOAD Payload\r |
4751a48a AC |
184 | );\r |
185 | \r | |
186 | /**\r | |
187 | Fill the input RedPath string with system UUID from SMBIOS table or use the customized\r | |
188 | ID if FromSmbios == FALSE.\r | |
189 | \r | |
190 | This is a helper function to build a RedPath string which can be used to address\r | |
191 | a Redfish resource for this computer system. The input PathString must have a Systems\r | |
192 | note in format of "Systems[UUID=%g]" or "Systems[UUID~%g]" to fill the UUID value.\r | |
193 | \r | |
194 | Example:\r | |
195 | Use "/v1/Systems[UUID=%g]/Bios" to build a RedPath to address the "Bios" resource\r | |
196 | for this computer system.\r | |
197 | \r | |
198 | @param[in] RedPath RedPath format to be build.\r | |
199 | @param[in] FromSmbios Get system UUID from SMBIOS as computer system instance ID.\r | |
200 | @param[in] IdString The computer system instance ID.\r | |
201 | \r | |
202 | @return Full RedPath with system UUID inside, or NULL if error happens.\r | |
203 | \r | |
204 | **/\r | |
205 | CHAR8 *\r | |
206 | EFIAPI\r | |
207 | RedfishBuildPathWithSystemUuid (\r | |
39de741e MK |
208 | IN CONST CHAR8 *RedPath,\r |
209 | IN BOOLEAN FromSmbios,\r | |
210 | IN CHAR8 *IdString OPTIONAL\r | |
4751a48a AC |
211 | );\r |
212 | \r | |
213 | /**\r | |
214 | Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers\r | |
215 | and Payload which record any HTTP response messages.\r | |
216 | \r | |
217 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
218 | redfish response data.\r | |
219 | \r | |
220 | @param[in] RedfishService The Service to access the Redfish resources.\r | |
221 | @param[in] RedPath RedPath string to address a resource, must start\r | |
222 | from the root node.\r | |
223 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
224 | \r | |
225 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
226 | NULL and the value is 2XX. The corresponding redfish resource has\r | |
227 | been returned in Payload within RedResponse.\r | |
228 | @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or RedResponse is NULL.\r | |
229 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
230 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
231 | within RedResponse:\r | |
232 | 1. If the returned Payload is NULL, indicates any error happen.\r | |
233 | 2. If the returned StatusCode is NULL, indicates any error happen.\r | |
234 | 3. If the returned StatusCode is not 2XX, indicates any error happen.\r | |
235 | **/\r | |
236 | EFI_STATUS\r | |
237 | EFIAPI\r | |
238 | RedfishGetByService (\r | |
39de741e MK |
239 | IN REDFISH_SERVICE RedfishService,\r |
240 | IN CONST CHAR8 *RedPath,\r | |
241 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
242 | );\r |
243 | \r | |
244 | /**\r | |
245 | Get a redfish response addressed by URI, including HTTP StatusCode, Headers\r | |
246 | and Payload which record any HTTP response messages.\r | |
247 | \r | |
248 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
249 | redfish response data.\r | |
250 | \r | |
251 | @param[in] RedfishService The Service to access the URI resources.\r | |
252 | @param[in] URI String to address a resource.\r | |
253 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
254 | \r | |
255 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
256 | NULL and the value is 2XX. The corresponding redfish resource has\r | |
257 | been returned in Payload within RedResponse.\r | |
258 | @retval EFI_INVALID_PARAMETER RedfishService, RedPath, or RedResponse is NULL.\r | |
259 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
260 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
261 | within RedResponse:\r | |
262 | 1. If the returned Payload is NULL, indicates any error happen.\r | |
263 | 2. If the returned StatusCode is NULL, indicates any error happen.\r | |
264 | 3. If the returned StatusCode is not 2XX, indicates any error happen.\r | |
265 | **/\r | |
266 | EFI_STATUS\r | |
267 | EFIAPI\r | |
268 | RedfishGetByUri (\r | |
39de741e MK |
269 | IN REDFISH_SERVICE RedfishService,\r |
270 | IN CONST CHAR8 *Uri,\r | |
271 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
272 | );\r |
273 | \r | |
274 | /**\r | |
275 | Get a redfish response addressed by the input Payload and relative RedPath string,\r | |
276 | including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r | |
277 | \r | |
278 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
279 | redfish response data.\r | |
280 | \r | |
281 | @param[in] Payload A existing REDFISH_PAYLOAD instance.\r | |
282 | @param[in] RedPath Relative RedPath string to address a resource inside Payload.\r | |
283 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
284 | \r | |
285 | @retval EFI_SUCCESS The opeartion is successful:\r | |
286 | 1. The HTTP StatusCode is NULL and the returned Payload in\r | |
287 | RedResponse is not NULL, indicates the Redfish resource has\r | |
288 | been parsed from the input payload directly.\r | |
289 | 2. The HTTP StatusCode is not NULL and the value is 2XX,\r | |
290 | indicates the corresponding redfish resource has been returned\r | |
291 | in Payload within RedResponse.\r | |
292 | @retval EFI_INVALID_PARAMETER Payload, RedPath, or RedResponse is NULL.\r | |
293 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
294 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
295 | within RedResponse:\r | |
296 | 1. If the returned Payload is NULL, indicates any error happen.\r | |
297 | 2. If StatusCode is not NULL and the returned value of StatusCode\r | |
298 | is not 2XX, indicates any error happen.\r | |
299 | **/\r | |
300 | EFI_STATUS\r | |
301 | EFIAPI\r | |
302 | RedfishGetByPayload (\r | |
39de741e MK |
303 | IN REDFISH_PAYLOAD Payload,\r |
304 | IN CONST CHAR8 *RedPath,\r | |
305 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
306 | );\r |
307 | \r | |
308 | /**\r | |
309 | Use HTTP PATCH to perform updates on pre-existing Redfish resource.\r | |
310 | \r | |
311 | This function uses the RedfishService to patch a Redfish resource addressed by\r | |
312 | Uri (only the relative path is required). Changes to one or more properties within\r | |
313 | the target resource are represented in the input Content, properties not specified\r | |
314 | in Content won't be changed by this request. The corresponding redfish response will\r | |
315 | returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r | |
316 | messages.\r | |
317 | \r | |
318 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
319 | redfish response data.\r | |
320 | \r | |
321 | @param[in] RedfishService The Service to access the Redfish resources.\r | |
322 | @param[in] Uri Relative path to address the resource.\r | |
323 | @param[in] Content JSON represented properties to be update.\r | |
324 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
325 | \r | |
326 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
327 | NULL and the value is 2XX. The Redfish resource will be returned\r | |
328 | in Payload within RedResponse if server send it back in the HTTP\r | |
329 | response message body.\r | |
330 | @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or RedResponse is NULL.\r | |
331 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
332 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
333 | within RedResponse:\r | |
334 | 1. If the returned StatusCode is NULL, indicates any error happen.\r | |
335 | 2. If the returned StatusCode is not NULL and the value is not 2XX,\r | |
336 | indicates any error happen.\r | |
337 | **/\r | |
338 | EFI_STATUS\r | |
339 | EFIAPI\r | |
340 | RedfishPatchToUri (\r | |
39de741e MK |
341 | IN REDFISH_SERVICE RedfishService,\r |
342 | IN CONST CHAR8 *Uri,\r | |
343 | IN CONST CHAR8 *Content,\r | |
344 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
345 | );\r |
346 | \r | |
347 | /**\r | |
348 | Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.\r | |
349 | \r | |
350 | This function uses the Payload to patch the Target. Changes to one or more properties\r | |
351 | within the target resource are represented in the input Payload, properties not specified\r | |
352 | in Payload won't be changed by this request. The corresponding redfish response will\r | |
353 | returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r | |
354 | messages.\r | |
355 | \r | |
356 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
357 | redfish response data.\r | |
358 | \r | |
359 | @param[in] Target The target payload to be updated.\r | |
360 | @param[in] Payload Palyoad with properties to be changed.\r | |
361 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
362 | \r | |
363 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
364 | NULL and the value is 2XX. The Redfish resource will be returned\r | |
365 | in Payload within RedResponse if server send it back in the HTTP\r | |
366 | response message body.\r | |
367 | @retval EFI_INVALID_PARAMETER Target, Payload, or RedResponse is NULL.\r | |
368 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
369 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
370 | within RedResponse:\r | |
371 | 1. If the returned StatusCode is NULL, indicates any error happen.\r | |
372 | 2. If the returned StatusCode is not NULL and the value is not 2XX,\r | |
373 | indicates any error happen.\r | |
374 | **/\r | |
375 | EFI_STATUS\r | |
376 | EFIAPI\r | |
377 | RedfishPatchToPayload (\r | |
39de741e MK |
378 | IN REDFISH_PAYLOAD Target,\r |
379 | IN REDFISH_PAYLOAD Payload,\r | |
380 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
381 | );\r |
382 | \r | |
383 | /**\r | |
384 | Use HTTP POST to create a new resource in target payload.\r | |
385 | \r | |
386 | The POST request should be submitted to the Resource Collection in which the new resource\r | |
387 | is to belong. The Resource Collection is addressed by Target payload. The Redfish may\r | |
388 | ignore any service controlled properties. The corresponding redfish response will returned,\r | |
389 | including HTTP StatusCode, Headers and Payload which record any HTTP response messages.\r | |
390 | \r | |
391 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
392 | redfish response data.\r | |
393 | \r | |
394 | @param[in] Target Target payload of the Resource Collection.\r | |
395 | @param[in] Payload The new resource to be created.\r | |
396 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
397 | \r | |
398 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
399 | NULL and the value is 2XX. The Redfish resource will be returned\r | |
400 | in Payload within RedResponse if server send it back in the HTTP\r | |
401 | response message body.\r | |
402 | @retval EFI_INVALID_PARAMETER Target, Payload, or RedResponse is NULL.\r | |
403 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
404 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
405 | within RedResponse:\r | |
406 | 1. If the returned StatusCode is NULL, indicates any error happen.\r | |
407 | 2. If the returned StatusCode is not NULL and the value is not 2XX,\r | |
408 | indicates any error happen.\r | |
409 | **/\r | |
410 | EFI_STATUS\r | |
411 | EFIAPI\r | |
412 | RedfishPostToPayload (\r | |
39de741e MK |
413 | IN REDFISH_PAYLOAD Target,\r |
414 | IN REDFISH_PAYLOAD Payload,\r | |
415 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
416 | );\r |
417 | \r | |
418 | /**\r | |
419 | Use HTTP DELETE to remove a resource.\r | |
420 | \r | |
421 | This function uses the RedfishService to remove a Redfish resource which is addressed\r | |
422 | by input Uri (only the relative path is required). The corresponding redfish response will\r | |
423 | returned, including HTTP StatusCode, Headers and Payload which record any HTTP response\r | |
424 | messages.\r | |
425 | \r | |
426 | Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in\r | |
427 | redfish response data.\r | |
428 | \r | |
429 | @param[in] RedfishService The Service to access the Redfish resources.\r | |
430 | @param[in] Uri Relative path to address the resource.\r | |
431 | @param[out] RedResponse Pointer to the Redfish response data.\r | |
432 | \r | |
433 | @retval EFI_SUCCESS The opeartion is successful, indicates the HTTP StatusCode is not\r | |
434 | NULL and the value is 2XX, the Redfish resource has been removed.\r | |
435 | If there is any message returned from server, it will be returned\r | |
436 | in Payload within RedResponse.\r | |
437 | @retval EFI_INVALID_PARAMETER RedfishService, Uri, or RedResponse is NULL.\r | |
438 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get\r | |
439 | more error info from returned HTTP StatusCode, Headers and Payload\r | |
440 | within RedResponse:\r | |
441 | 1. If the returned StatusCode is NULL, indicates any error happen.\r | |
442 | 2. If the returned StatusCode is not NULL and the value is not 2XX,\r | |
443 | indicates any error happen.\r | |
444 | **/\r | |
445 | EFI_STATUS\r | |
446 | EFIAPI\r | |
447 | RedfishDeleteByUri (\r | |
39de741e MK |
448 | IN REDFISH_SERVICE RedfishService,\r |
449 | IN CONST CHAR8 *Uri,\r | |
450 | OUT REDFISH_RESPONSE *RedResponse\r | |
4751a48a AC |
451 | );\r |
452 | \r | |
453 | /**\r | |
454 | Dump text in fractions.\r | |
455 | \r | |
456 | @param[in] String ASCII string to dump.\r | |
457 | \r | |
458 | **/\r | |
459 | VOID\r | |
460 | RedfishDumpJsonStringFractions (\r | |
39de741e | 461 | IN CHAR8 *String\r |
4751a48a AC |
462 | );\r |
463 | \r | |
464 | /**\r | |
465 | Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.\r | |
466 | \r | |
467 | @param[in] Payload The Redfish payload to dump.\r | |
468 | \r | |
469 | **/\r | |
470 | VOID\r | |
471 | RedfishDumpPayload (\r | |
39de741e | 472 | IN REDFISH_PAYLOAD Payload\r |
4751a48a | 473 | );\r |
39de741e | 474 | \r |
4751a48a AC |
475 | /**\r |
476 | Dump text in JSON value.\r | |
477 | \r | |
478 | @param[in] JsonValue The Redfish JSON value to dump.\r | |
479 | \r | |
480 | **/\r | |
481 | VOID\r | |
482 | RedfishDumpJson (\r | |
483 | IN EDKII_JSON_VALUE JsonValue\r | |
484 | );\r | |
39de741e | 485 | \r |
4751a48a AC |
486 | /**\r |
487 | This function will cleanup the HTTP header and Redfish payload resources.\r | |
488 | \r | |
489 | @param[in] StatusCode The status code in HTTP response message.\r | |
490 | @param[in] HeaderCount Number of HTTP header structures in Headers list.\r | |
491 | @param[in] Headers Array containing list of HTTP headers.\r | |
492 | @param[in] Payload The Redfish payload to dump.\r | |
493 | \r | |
494 | **/\r | |
495 | VOID\r | |
496 | RedfishFreeResponse (\r | |
497 | IN EFI_HTTP_STATUS_CODE *StatusCode,\r | |
498 | IN UINTN HeaderCount,\r | |
499 | IN EFI_HTTP_HEADER *Headers,\r | |
500 | IN REDFISH_PAYLOAD Payload\r | |
501 | );\r | |
502 | \r | |
503 | /**\r | |
504 | Check if the "@odata.type" in Payload is valid or not.\r | |
505 | \r | |
506 | @param[in] Payload The Redfish payload to be checked.\r | |
507 | @param[in] OdataTypeName OdataType will be retrived from mapping list.\r | |
508 | @param[in] OdataTypeMappingList The list of OdataType.\r | |
509 | @param[in] OdataTypeMappingListSize The number of mapping list\r | |
510 | \r | |
511 | @return TRUE if the "@odata.type" in Payload is valid, otherwise FALSE.\r | |
512 | \r | |
513 | **/\r | |
514 | BOOLEAN\r | |
515 | RedfishIsValidOdataType (\r | |
39de741e MK |
516 | IN REDFISH_PAYLOAD Payload,\r |
517 | IN CONST CHAR8 *OdataTypeName,\r | |
518 | IN REDFISH_ODATA_TYPE_MAPPING *OdataTypeMappingList,\r | |
519 | IN UINTN OdataTypeMappingListSize\r | |
4751a48a AC |
520 | );\r |
521 | \r | |
522 | /**\r | |
523 | Check if the payload is collection\r | |
524 | \r | |
525 | @param[in] Payload The Redfish payload to be checked.\r | |
526 | \r | |
527 | @return TRUE if the payload is collection.\r | |
528 | \r | |
529 | **/\r | |
530 | BOOLEAN\r | |
531 | RedfishIsPayloadCollection (\r | |
39de741e MK |
532 | IN REDFISH_PAYLOAD Payload\r |
533 | );\r | |
534 | \r | |
4751a48a AC |
535 | /**\r |
536 | Get collection size.\r | |
537 | \r | |
538 | @param[in] Payload The Redfish collection payload\r | |
539 | @param[in] CollectionSize Size of this collection\r | |
540 | \r | |
541 | @return EFI_SUCCESS Coolection size is returned in CollectionSize\r | |
542 | @return EFI_INVALID_PARAMETER The payload is not a collection.\r | |
543 | **/\r | |
544 | EFI_STATUS\r | |
39de741e MK |
545 | RedfishGetCollectionSize (\r |
546 | IN REDFISH_PAYLOAD Payload,\r | |
547 | IN UINTN *CollectionSize\r | |
548 | );\r | |
549 | \r | |
4751a48a AC |
550 | /**\r |
551 | Get Redfish payload of collection member\r | |
552 | \r | |
553 | @param[in] Payload The Redfish collection payload\r | |
554 | @param[in] Index Index of collection member\r | |
555 | \r | |
556 | @return NULL Fail to get collection member.\r | |
557 | @return Non NULL Payload is returned.\r | |
558 | **/\r | |
559 | REDFISH_PAYLOAD\r | |
560 | RedfishGetPayloadByIndex (\r | |
39de741e MK |
561 | IN REDFISH_PAYLOAD Payload,\r |
562 | IN UINTN Index\r | |
563 | );\r | |
4751a48a AC |
564 | \r |
565 | /**\r | |
566 | Check and return Redfish resource of the given Redpath.\r | |
567 | \r | |
568 | @param[in] RedfishService Pointer to REDFISH_SERVICE\r | |
569 | @param[in] Redpath Redpath of the resource.\r | |
570 | @param[in] Response Optional return the resource.\r | |
571 | \r | |
572 | @return EFI_STATUS\r | |
573 | **/\r | |
574 | EFI_STATUS\r | |
575 | RedfishCheckIfRedpathExist (\r | |
39de741e MK |
576 | IN REDFISH_SERVICE RedfishService,\r |
577 | IN CHAR8 *Redpath,\r | |
578 | IN REDFISH_RESPONSE *Response OPTIONAL\r | |
579 | );\r | |
4751a48a AC |
580 | \r |
581 | /**\r | |
582 | This function returns the string of Redfish service version.\r | |
583 | \r | |
584 | @param[in] RedfishService Redfish service instance.\r | |
585 | @param[out] ServiceVersionStr Redfish service string.\r | |
586 | \r | |
587 | @return EFI_STATUS\r | |
588 | \r | |
589 | **/\r | |
590 | EFI_STATUS\r | |
39de741e MK |
591 | RedfishGetServiceVersion (\r |
592 | IN REDFISH_SERVICE RedfishService,\r | |
593 | OUT CHAR8 **ServiceVersionStr\r | |
4751a48a AC |
594 | );\r |
595 | \r | |
596 | /**\r | |
597 | This function returns the string of Redfish service version.\r | |
598 | \r | |
599 | @param[in] ServiceVerisonStr The string of Redfish service version.\r | |
600 | @param[in] Url The URL to build Redpath with ID.\r | |
601 | Start with "/", for example "/Registries"\r | |
602 | @param[in] Id ID string\r | |
603 | @param[out] Redpath Pointer to retrive Redpath, caller has to free\r | |
604 | the memory allocated for this string.\r | |
605 | @return EFI_STATUS\r | |
606 | \r | |
607 | **/\r | |
608 | EFI_STATUS\r | |
609 | RedfishBuildRedpathUseId (\r | |
39de741e MK |
610 | IN CHAR8 *ServiceVerisonStr,\r |
611 | IN CHAR8 *Url,\r | |
612 | IN CHAR8 *Id,\r | |
613 | OUT CHAR8 **Redpath\r | |
4751a48a | 614 | );\r |
39de741e | 615 | \r |
4751a48a | 616 | #endif\r |