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