Files
c/kubernetes/model/v1_config_map_volume_source.c
Hui Yu 732348e69e Re-generate the C client to merge recent changes from openapi-generator:
1. [C][Client] Add C++ reserved keywords to C-libcurl client generator,then the C client can be compiled by C++ compiler (#8205)

2. [C][Client] Disable escaping the parameter name in URL path string (#8243)

3. [C][Client] Fix coredump when releasing the memory of an incompleted model (#8190)
2021-01-05 15:42:34 +08:00

166 lines
4.7 KiB
C

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "v1_config_map_volume_source.h"
v1_config_map_volume_source_t *v1_config_map_volume_source_create(
int default_mode,
list_t *items,
char *name,
int optional
) {
v1_config_map_volume_source_t *v1_config_map_volume_source_local_var = malloc(sizeof(v1_config_map_volume_source_t));
if (!v1_config_map_volume_source_local_var) {
return NULL;
}
v1_config_map_volume_source_local_var->default_mode = default_mode;
v1_config_map_volume_source_local_var->items = items;
v1_config_map_volume_source_local_var->name = name;
v1_config_map_volume_source_local_var->optional = optional;
return v1_config_map_volume_source_local_var;
}
void v1_config_map_volume_source_free(v1_config_map_volume_source_t *v1_config_map_volume_source) {
if(NULL == v1_config_map_volume_source){
return ;
}
listEntry_t *listEntry;
if (v1_config_map_volume_source->items) {
list_ForEach(listEntry, v1_config_map_volume_source->items) {
v1_key_to_path_free(listEntry->data);
}
list_free(v1_config_map_volume_source->items);
v1_config_map_volume_source->items = NULL;
}
if (v1_config_map_volume_source->name) {
free(v1_config_map_volume_source->name);
v1_config_map_volume_source->name = NULL;
}
free(v1_config_map_volume_source);
}
cJSON *v1_config_map_volume_source_convertToJSON(v1_config_map_volume_source_t *v1_config_map_volume_source) {
cJSON *item = cJSON_CreateObject();
// v1_config_map_volume_source->default_mode
if(v1_config_map_volume_source->default_mode) {
if(cJSON_AddNumberToObject(item, "defaultMode", v1_config_map_volume_source->default_mode) == NULL) {
goto fail; //Numeric
}
}
// v1_config_map_volume_source->items
if(v1_config_map_volume_source->items) {
cJSON *items = cJSON_AddArrayToObject(item, "items");
if(items == NULL) {
goto fail; //nonprimitive container
}
listEntry_t *itemsListEntry;
if (v1_config_map_volume_source->items) {
list_ForEach(itemsListEntry, v1_config_map_volume_source->items) {
cJSON *itemLocal = v1_key_to_path_convertToJSON(itemsListEntry->data);
if(itemLocal == NULL) {
goto fail;
}
cJSON_AddItemToArray(items, itemLocal);
}
}
}
// v1_config_map_volume_source->name
if(v1_config_map_volume_source->name) {
if(cJSON_AddStringToObject(item, "name", v1_config_map_volume_source->name) == NULL) {
goto fail; //String
}
}
// v1_config_map_volume_source->optional
if(v1_config_map_volume_source->optional) {
if(cJSON_AddBoolToObject(item, "optional", v1_config_map_volume_source->optional) == NULL) {
goto fail; //Bool
}
}
return item;
fail:
if (item) {
cJSON_Delete(item);
}
return NULL;
}
v1_config_map_volume_source_t *v1_config_map_volume_source_parseFromJSON(cJSON *v1_config_map_volume_sourceJSON){
v1_config_map_volume_source_t *v1_config_map_volume_source_local_var = NULL;
// v1_config_map_volume_source->default_mode
cJSON *default_mode = cJSON_GetObjectItemCaseSensitive(v1_config_map_volume_sourceJSON, "defaultMode");
if (default_mode) {
if(!cJSON_IsNumber(default_mode))
{
goto end; //Numeric
}
}
// v1_config_map_volume_source->items
cJSON *items = cJSON_GetObjectItemCaseSensitive(v1_config_map_volume_sourceJSON, "items");
list_t *itemsList;
if (items) {
cJSON *items_local_nonprimitive;
if(!cJSON_IsArray(items)){
goto end; //nonprimitive container
}
itemsList = list_create();
cJSON_ArrayForEach(items_local_nonprimitive,items )
{
if(!cJSON_IsObject(items_local_nonprimitive)){
goto end;
}
v1_key_to_path_t *itemsItem = v1_key_to_path_parseFromJSON(items_local_nonprimitive);
list_addElement(itemsList, itemsItem);
}
}
// v1_config_map_volume_source->name
cJSON *name = cJSON_GetObjectItemCaseSensitive(v1_config_map_volume_sourceJSON, "name");
if (name) {
if(!cJSON_IsString(name))
{
goto end; //String
}
}
// v1_config_map_volume_source->optional
cJSON *optional = cJSON_GetObjectItemCaseSensitive(v1_config_map_volume_sourceJSON, "optional");
if (optional) {
if(!cJSON_IsBool(optional))
{
goto end; //Bool
}
}
v1_config_map_volume_source_local_var = v1_config_map_volume_source_create (
default_mode ? default_mode->valuedouble : 0,
items ? itemsList : NULL,
name ? strdup(name->valuestring) : NULL,
optional ? optional->valueint : 0
);
return v1_config_map_volume_source_local_var;
end:
return NULL;
}