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