2020-03-18 17:24:33 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "v1_persistent_volume_status.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v1_persistent_volume_status_t *v1_persistent_volume_status_create(
|
2023-09-06 01:56:31 +00:00
|
|
|
char *last_phase_transition_time,
|
2020-03-18 17:24:33 +08:00
|
|
|
char *message,
|
2022-06-05 18:16:17 +00:00
|
|
|
char *phase,
|
2020-03-18 17:24:33 +08:00
|
|
|
char *reason
|
|
|
|
|
) {
|
|
|
|
|
v1_persistent_volume_status_t *v1_persistent_volume_status_local_var = malloc(sizeof(v1_persistent_volume_status_t));
|
|
|
|
|
if (!v1_persistent_volume_status_local_var) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2023-09-06 01:56:31 +00:00
|
|
|
v1_persistent_volume_status_local_var->last_phase_transition_time = last_phase_transition_time;
|
2020-03-18 17:24:33 +08:00
|
|
|
v1_persistent_volume_status_local_var->message = message;
|
|
|
|
|
v1_persistent_volume_status_local_var->phase = phase;
|
|
|
|
|
v1_persistent_volume_status_local_var->reason = reason;
|
|
|
|
|
|
|
|
|
|
return v1_persistent_volume_status_local_var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void v1_persistent_volume_status_free(v1_persistent_volume_status_t *v1_persistent_volume_status) {
|
|
|
|
|
if(NULL == v1_persistent_volume_status){
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
listEntry_t *listEntry;
|
2023-09-06 01:56:31 +00:00
|
|
|
if (v1_persistent_volume_status->last_phase_transition_time) {
|
|
|
|
|
free(v1_persistent_volume_status->last_phase_transition_time);
|
|
|
|
|
v1_persistent_volume_status->last_phase_transition_time = NULL;
|
|
|
|
|
}
|
2021-01-05 15:42:34 +08:00
|
|
|
if (v1_persistent_volume_status->message) {
|
|
|
|
|
free(v1_persistent_volume_status->message);
|
|
|
|
|
v1_persistent_volume_status->message = NULL;
|
|
|
|
|
}
|
2022-06-05 18:16:17 +00:00
|
|
|
if (v1_persistent_volume_status->phase) {
|
|
|
|
|
free(v1_persistent_volume_status->phase);
|
|
|
|
|
v1_persistent_volume_status->phase = NULL;
|
|
|
|
|
}
|
2021-01-05 15:42:34 +08:00
|
|
|
if (v1_persistent_volume_status->reason) {
|
|
|
|
|
free(v1_persistent_volume_status->reason);
|
|
|
|
|
v1_persistent_volume_status->reason = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
free(v1_persistent_volume_status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cJSON *v1_persistent_volume_status_convertToJSON(v1_persistent_volume_status_t *v1_persistent_volume_status) {
|
|
|
|
|
cJSON *item = cJSON_CreateObject();
|
|
|
|
|
|
2023-09-06 01:56:31 +00:00
|
|
|
// v1_persistent_volume_status->last_phase_transition_time
|
|
|
|
|
if(v1_persistent_volume_status->last_phase_transition_time) {
|
|
|
|
|
if(cJSON_AddStringToObject(item, "lastPhaseTransitionTime", v1_persistent_volume_status->last_phase_transition_time) == NULL) {
|
|
|
|
|
goto fail; //Date-Time
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-03-18 17:24:33 +08:00
|
|
|
// v1_persistent_volume_status->message
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_persistent_volume_status->message) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "message", v1_persistent_volume_status->message) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_persistent_volume_status->phase
|
2022-06-05 18:16:17 +00:00
|
|
|
if(v1_persistent_volume_status->phase) {
|
|
|
|
|
if(cJSON_AddStringToObject(item, "phase", v1_persistent_volume_status->phase) == NULL) {
|
|
|
|
|
goto fail; //String
|
2020-03-18 17:24:33 +08:00
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_persistent_volume_status->reason
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_persistent_volume_status->reason) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "reason", v1_persistent_volume_status->reason) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
fail:
|
|
|
|
|
if (item) {
|
|
|
|
|
cJSON_Delete(item);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v1_persistent_volume_status_t *v1_persistent_volume_status_parseFromJSON(cJSON *v1_persistent_volume_statusJSON){
|
|
|
|
|
|
|
|
|
|
v1_persistent_volume_status_t *v1_persistent_volume_status_local_var = NULL;
|
|
|
|
|
|
2023-09-06 01:56:31 +00:00
|
|
|
// v1_persistent_volume_status->last_phase_transition_time
|
|
|
|
|
cJSON *last_phase_transition_time = cJSON_GetObjectItemCaseSensitive(v1_persistent_volume_statusJSON, "lastPhaseTransitionTime");
|
|
|
|
|
if (last_phase_transition_time) {
|
|
|
|
|
if(!cJSON_IsString(last_phase_transition_time) && !cJSON_IsNull(last_phase_transition_time))
|
|
|
|
|
{
|
|
|
|
|
goto end; //DateTime
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 17:24:33 +08:00
|
|
|
// v1_persistent_volume_status->message
|
|
|
|
|
cJSON *message = cJSON_GetObjectItemCaseSensitive(v1_persistent_volume_statusJSON, "message");
|
|
|
|
|
if (message) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(message) && !cJSON_IsNull(message))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_persistent_volume_status->phase
|
|
|
|
|
cJSON *phase = cJSON_GetObjectItemCaseSensitive(v1_persistent_volume_statusJSON, "phase");
|
|
|
|
|
if (phase) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(phase) && !cJSON_IsNull(phase))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
2022-06-05 18:16:17 +00:00
|
|
|
goto end; //String
|
2020-03-18 17:24:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_persistent_volume_status->reason
|
|
|
|
|
cJSON *reason = cJSON_GetObjectItemCaseSensitive(v1_persistent_volume_statusJSON, "reason");
|
|
|
|
|
if (reason) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(reason) && !cJSON_IsNull(reason))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v1_persistent_volume_status_local_var = v1_persistent_volume_status_create (
|
2023-09-06 01:56:31 +00:00
|
|
|
last_phase_transition_time && !cJSON_IsNull(last_phase_transition_time) ? strdup(last_phase_transition_time->valuestring) : NULL,
|
2022-12-29 10:58:47 +08:00
|
|
|
message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL,
|
|
|
|
|
phase && !cJSON_IsNull(phase) ? strdup(phase->valuestring) : NULL,
|
|
|
|
|
reason && !cJSON_IsNull(reason) ? strdup(reason->valuestring) : NULL
|
2020-03-18 17:24:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return v1_persistent_volume_status_local_var;
|
|
|
|
|
end:
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|